Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!

# The Machine Game

Pratik Lohia
Ranch Hand
Posts: 88
Anyone who wanna try this?
Quite and old and comon game...

I got 10 machines dishing out coins of 10 grams each.... One machine becomes faulty and dishes out an 11 gram coin.
With just one try on an electronic display weighing scale, how do i determine the faulty one?

Ranch Hand
Posts: 628
set the machine such that the 1 st machine dishes out 1 coin..2nd machine 2 cone....10th machine 10 coin...

Now summation of all coins =10(1+2...10)= 10*10*11/2=550---1

Now weigh all the coins...you will get X----2

Now subtract 1 from 2 and then divide by 10 you will get the answer...

Ryan McGuire
Ranch Hand
Posts: 1072
4
Originally posted by Pratik Lohia:
Anyone who wanna try this?
Quite and old and comon game...

I got 10 machines dishing out coins of 10 grams each.... One machine becomes faulty and dishes out an 11 gram coin.
With just one try on an electronic display weighing scale, how do i determine the faulty one?

This type of problem has been popping up in the Programming Diversions forum even though it doesn't really have much to do with programming.

Anyhow...

Grab...
1 coin from machine 1 plus
8 coins from machine 2 plus
7 coins from machine 3 plus
4 coins from machine 4 plus
5 coins from machine 5 plus
6 coins from machine 6 plus
3 coins from machine 7 plus
2 coins from machine 8 plus
9 coins from machine 9 plus
10 coins from machine 10

Weigh them all together. Cube that result. The last digit of that result shows the malfunctioning machine (last digit==0 -> machine 10).