#!/usr/bin/perl use strict; my @chars = 'a'..'m'; my %hands; for my $c0 (@chars) { for my $c1 (@chars) { for my $c2 (@chars) { for my $c3 (@chars) { for my $c4 (@chars) { my $list = [$c0, $c1, $c2, $c3, $c4]; my $uniq = unique_ranks($list); my $key = join('', sort @$list ); # is a valid hand if ($uniq > 1) { $hands{$key}++; } # can be flushed if ($uniq > 4) { $hands{"$key+"}++; } } } } } } for my $key (sort(keys(%hands))) { $key =~ tr/a-m/AKQJT98765432/; print "$key\n"; } #----------------------------------------------------------- sub unique_ranks { my $list = shift; my %uniq = map { ($_ => 1) } @$list; return keys %uniq; }