Set puzzle: Difference between revisions

Content added Content deleted
(→‎{{header|Perl 6}}: some clarifications)
Line 427: Line 427:


=={{header|Perl 6}}==
=={{header|Perl 6}}==
This uses the <tt>combine</tt> routine from [[Combinations#Perl_6]] task. The trick here is to OR all the bits together to make an octal digit for each enum, with the result that the cards of a matching set produce a 4-digit octal numbers that contains only the digits 1, 2, 4, or 7.
This uses the <tt>combine</tt> routine from [[Combinations#Perl_6]] task. The trick here is to allocate three different bits for each enum, with the result that the cards of a matching set OR together to produce a 4-digit octal number that contains only the digits 1, 2, 4, or 7. This OR is done by funny looking <tt>[+|]</tt>, which is the reduction form of <tt>+|</tt>, which is the numeric bitwise OR. (Because Perl 6 stole the bare <tt>|</tt> operator for composing junctions instead.)
<lang perl6>enum Color (red => 512, green => 1024, purple => 2048);
<lang perl6>enum Color (red => 512, green => 1024, purple => 2048);
enum Count (one => 64, two => 128, three => 256);
enum Count (one => 64, two => 128, three => 256);
Line 485: Line 485:
red three diamond solid
red three diamond solid
purple two diamond striped</pre>
purple two diamond striped</pre>

=={{header|Python}}==
=={{header|Python}}==
<lang python>#!/usr/bin/python
<lang python>#!/usr/bin/python