473,385 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Guess the faulty machine

ashitpro
542 Expert 512MB
There are 7 machines, each of them produces the coin of weight 2 grams.
Someday somehow one machine gets faulty and started producing coin of weight 1 gram. All coins looks similar in dimensions.
You can take any number of coins from any machine.
Condition is that, whatever coins taken from 7 machines would be weighted only once.
Can somebody find the faulty machine.
Sep 26 '07 #1
5 1281
Nepomuk
3,112 Expert 2GB
There are 7 machines, each of them produces the coin of weight 2 grams.
Someday somehow one machine gets faulty and started producing coin of weight 1 gram. All coins looks similar in dimensions.
You can take any number of coins from any machine.
Condition is that, whatever coins taken from 7 machines would be weighted only once.
Can somebody find the faulty machine.
Let's say, the machines are called m0 - m6. Take 2^0 = 1 coin from m0, 2^1 = 2 coins from m1 and so on. So if all machines work correctly, you should have 1*2 + 2*2 + 4*2 + 8*2 + 16*2 + 32*2 + 64*2 = 127*2 = 254 grams.

Say, m3 is faulty. Then you'll have 1*2 + 2*2 + 4*2 + 8*1 + 16*2 + 32*2 + 64*2 = 127*2 - 8 = 246 grams. So basically, you take those coins, weigh them and the difference between the weight and 254 grams gives you the faulty machine (2^X difference -> mX is faulty).

Where's the next question? ^^

Greetings,
Nepomuk
Sep 26 '07 #2
sitko
140 100+
Wouldn't it make more sense, to make each subgrouping get bigger by a factor of 10, instead of a factor of 2?

Then you'd get a lot more coins that you could spend after the problem is solved.

:)
Oct 3 '07 #3
Banfa
9,065 Expert Mod 8TB
Wouldn't it make more sense to use an arithmetic progression rather than a geometric one.

That is rather than 2^0, 2^1, 2^2, 2^2 ... take 1, 2, 3, 4, 5, 6, 7, then the number of grams you are short is the machine number + 1.
Oct 3 '07 #4
sitko
140 100+
Wouldn't it make more sense to use an arithmetic progression rather than a geometric one.

That is rather than 2^0, 2^1, 2^2, 2^2 ... take 1, 2, 3, 4, 5, 6, 7, then the number of grams you are short is the machine number + 1.
No, I know that wouldn't work. It would be more confusing to figure out specifically which subgroup of coins was the culprit.

as if 6 was the bad one, it would weigh the same as a good 3, ...maybe it would work...I'll let smarter people chime in...

:)
Oct 3 '07 #5
jkmyoung
2,057 Expert 2GB
Banfa's correct. Using powers of 2 just complicates things.

I think the assumption missed is that all the coins you get from the 7 machines are weighed altogether.
Oct 4 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: EAS | last post by:
Hey, I'm new to python (and programming in general) so I'll prolly be around here a lot... Anyways, I've found out how to make a "guess my number game" where the player guesses a number between...
9
by: Marina Anufreichik | last post by:
Hi, After deploymnet web application on web server I can access page on local machine and login fine but when I'm trying to access web site from remote machine I can see login page, but when I'm...
7
by: Anjali M | last post by:
#include<stdio.h> int main() { int a = 10; switch(a) { case '1': printf("ONE\n"); break; case '2':
27
by: Javier Martinez | last post by:
Hi I have asp application in a machine with a virtual directory referring a shared directory in another machine When I try to load any aspx page of my portal I get the following error: ...
11
by: TARUN | last post by:
Hello All I need to ask about the configuration file in .NET, There are Two config File 1. Web Config 2. Machine config I understand the the usage of Web config , but not able to understand...
3
by: Neil Cerutti | last post by:
How do I cope with faulty encoding settings? I'm writing an application that needs all internal character data to be stored in iso-8859-1. It also must allow input and output using stdin and...
16
by: shana07 | last post by:
What's that mean by faulty program in java? I am told that it is any wrong in calculation for numerical program. Really appreciate if someone could give examples here to clarify about this topic. ...
166
by: Nimmi Srivastav | last post by:
Apologies if my cross posting has offended anyone.... For a pure hobbyist C/C++ programmer, who wants to develop applications to run on Windows, what would be a better choice to install: Visual...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.