Syntactic Confectionery Delight | |
PerlMonks |
Partition in to 63 partsby gam3 (Curate) |
on Jan 17, 2010 at 21:43 UTC ( [id://817901]=note: print w/replies, xml ) | Need Help?? |
The secret is that there are only 63 bits and that any number with a certain bit set can not 'match' any number with that same bit set. So all you need to do is get a list of all the elements with a bit set and compare them with all of the numbers with out that bit set. By using a hash in place of the list we can do this pretty efficiently.
note: It is also easy to split the problem up into 63 problems and use POE or some such to run each on a separate processor -- if you have 63 processors on your computer.
-- gam3 A picture is worth a thousand words, but takes 200K.
In Section
Seekers of Perl Wisdom
|
|