No such thing as a small change PerlMonks

### Re: Odd Ball Challenge

by barrachois (Pilgrim)
 on Jul 13, 2005 at 18:07 UTC ( #474643=note: print w/ replies, xml ) Need Help??

in reply to Odd Ball Challenge

A nice question; thanks. I had fun with it.

Here's some code that does an exhaustive search for a specific number of balls and weighings, from 3 balls and 2 weighings up to about 20 balls and 4 weighings. Full documentation (POD format) is included.

To give you an idea of what it does, a snip of the output looks like this:

Searching for odd ball in 12 balls with 3 weighings ...
'' : at node=1
... 1 partitions (4 L's, 0 different)
'b' : at node=2
... 11 partitions (1 L's, 4 different)
... 32 partitions (2 L's, 4 different)
'bb' : at node=3
... 2 partitions (1 L's, 1 different)
'bl' : at node=7
... 7 partitions (1 L's, 3 different)
'br' : at node=11
... 7 partitions (1 L's, 3 different)
etc.
done.  Solution found after 40 nodes and 2147 partitions.

start => [ L L L L R R R R o o o o ]

b => [ R o o o o o o o L L R o ]
l => [ L R o o L L R R o o o o ]
r => [ L L R R L R o o o o o o ]

bb => [ R o o o o o o o o o o L ]
bl => [ o o o o o o o o L R o o ]
br => [ o o o o o o o o L R o o ]
lb => [ o o L R o o o o o o o o ]
etc.

bbl => ball 12 is heavy.
bbr => ball 12 is light.
blb => ball 11 is light.
bll => ball 9 is heavy.
blr => ball 10 is heavy.
etc.

I should warn you that code isn't exactly brief...

Regards,
barrachois

Comment on Re: Odd Ball Challenge

Create A New User
Node Status?
node history
Node Type: note [id://474643]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2015-02-28 18:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?