#!/usr/bin/env perl -w while ($line = ) { #Input in way more every workable format @numbers = split(',',$line); #Get the number of every colour in on every line @colour = (0, 0, 0, 0, 0); foreach (0,2,4,6,8) { $colour[$numbers[$_]]++; } #Find pairs, triples, four @cards = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); foreach (1,3,5,7,9) { $cards[$numbers[$_]]++; } ### BEGIN Specials ### #triple = 1, four = 2 $special = 0; #one pair = 1, two pair = 2 $pairs = 0; ### END Specials ### ### BEGIN decoded specials ### $onepair = 0; $twopair = 0; $triple = 0; $four = 0; ### END decoded specials ### foreach (1 .. 13) { if ($cards[$_] == 2) { $pairs++; if ($pairs == 1) { $onepair = 1; } elsif ($pairs == 2) { $twopair = 1; } } elsif ($cards[$_] > 2) { $special = $cards[$_]; if ( $special == 3) { $triple = 1; } elsif ($special == 4) { $four = 1; } } } #Decode into split option array @output = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $output[$numbers[10]]++; $pairs /= 10; $special /= 10; foreach (0 .. 10) { $numbers[$_] /= 10; } foreach (0 .. 4) { $colour[$_] /= 10; } # Input 10 : all cards # Output 1 : decoded version of result #print "@numbers[0..10]\n"; # Input 10 : all cards # Output 10 : all options, one node print "@numbers[0..9] @output[0..9]\n"; # Input 14 : all cards + colours # Output 10 : all options, one node #print "@numbers[0..9] @colour[1..4] @output[0..9]\n"; # Input 16 : all cards + specials # Output 10 : all options, every has it's one node #print "@numbers[0..9] @colour[1..4] $pairs $special @output[0..9]\n"; # Input 14 : all cards + decoded specials # Output 10 : all options, every has it's one node #print "@numbers[0..9] $onepair $twopair $triple $four @output[0..9]\n"; # Input 18 : all cards + colour + decoded specials # Output 10 : all options, every has it's one node #print "@numbers[0..9] @colour[1..4] $onepair $twopair $triple $four @output[0..9]\n"; # Input 10: all cards # output 2: full house, four of a kind #print "@numbers[0..9] $output[6] $output[7]\n"; # Input 16 : all cards + specials # output 1 : full house #print "@numbers[0..9] @colour[1..4] $pairs $special $output[7]\n"; # Input 2 : Calculated set # output 1 : full house #print "$pair $special $output[6]\n"; # Input 8 : colour + decoded specials # Output 10 : all options, every has it's one node #print "@colour[1..4] $onepair $twopair $triple $four @output[0..9]\n"; }