P is for Practical  
PerlMonks 
Sets Puzzleby artist (Parson) 
on Jul 08, 2003 at 17:51 UTC ( #272360=CUFP: print w/ replies, xml )  Need Help?? 
Solution for:Sets Puzzle
The object of the game is to identify the 6 'Sets', of three cards each, from 12 cards laid out on the screen. Each card has a variation of the following four features:
Update 1:
Red Diamond 2 openwill have ID: 2121, with each digit representing the feature in order. Similarly, Purple Diamond 1 openwill have ID: 3131. Interesting part was to decide the match: I noticed that if I pick any two of the ID and third matching ID should be unique. Example, 1112 and 2213, then the third ID must be 3311. (12=>3 (different), 12=>3(different), 11=>1(unique), 23=>1(different)) If it is there in the given cards, we have found the set. Coming with calculation of 3rd ID was intersting, as I noticed that digits in the sum of each matching IDs (first,second and third) are even divisor of '3'. This algorithm, I found very interesting. Thanks to halley and demerphq in chatterbox for interesting suggestions.
__DATA__ Green Diamond 3 open Red Squiggle 2 open Red Oval 2 solid Purple Diamond 2 open Red Squiggle 1 open Green Oval 3 solid Green Squiggle 1 open Purple Diamond 1 open Red Squiggle 2 stripped Red Diamond 3 stripped Green Oval 2 open Red Diamond 2 openOutput: ======================================= 1 Green Diamond 3 open 7 Green Squiggle 1 open 11 Green Oval 2 open xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 1 Green Diamond 3 open 12 Red Diamond 2 open 8 Purple Diamond 1 open xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 6 Green Oval 3 solid 9 Red Squiggle 2 stripped 8 Purple Diamond 1 open xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 11 Green Oval 2 open 2 Red Squiggle 2 open 4 Purple Diamond 2 open xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 10 Red Diamond 3 stripped 5 Red Squiggle 1 open 3 Red Oval 2 solid xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 12 Red Diamond 2 open 9 Red Squiggle 2 stripped 3 Red Oval 2 solid xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxartist
Back to
Cool Uses for Perl

