Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: Odd Ball Challenge

by kaif (Friar)
on Jun 25, 2005 at 21:42 UTC ( [id://469962]=note: print w/replies, xml ) Need Help??


in reply to Re: Odd Ball Challenge
in thread Odd Ball Challenge

Good thinking. As djohnston concluded, such a strategy does exist. As you say, it does and must use the information of which side of the scale went up. My solution above uses a fixed strategy, actually. Try it out! Here's a detailed explanation of the strategy it uses:

Label your balls as follows:

001 (221) 011 (211) 012 (210) 022 (200) 100 (122) 110 (112) 120 (102) 121 (101) 201 (021) 202 (020) 212 (010) 220 (002)
where the first number is the primary label of the ball and the second is the secondary label (to be used later). Now use the following weighings, focusing on the primary labels only:

  1. (balls labelled with 0 in the first position) vs (balls labelled with 2 in the first position)
  2. ... the second position ...
  3. ... the third position ...

(Note: for reasons of golfing, my program runs the weighings in backwards order.) Now, for the result of each weighing, write 0 if the left side was heavier, 1 if it was a tie, and 2 if the right side was heavier. You should have a three-digit number. If the number is one of the primary labels above, then that ball was the unique heavier ball, and if it was one of the secondary labels, it was the unique lighter ball.

This method can be generalized (that is, with 4 weighings you can solve the same problem for 39 == (3**4 - 3) / 2 balls)! If you notice above that the primary and secondary labels are "dual" in a sense (in base 3 they sum to 26 --- i.e., 0s are replaced with 2s and vice-versa), then the problem actually comes down to finding a way of choosing the primary/secondary distinction in such a way that the weighings I described above each lead to (4 ball) vs (4 ball) comparisons. It so happens that the above labelling accomplishes the task. In general, this is a problem of coding theory.

I hope that my explanation was helpful. If anyone would like for me to do so, I can explain the code for my solution above in more detail.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://469962]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2024-04-25 04:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found