chomp($_ = ); @_ = split(' ', $_); my %hash = (); foreach (@_) { $hash{$_}++; } my $result = 0; while (my ($key, $val) = each(%hash)) { if ($result == 0) { $result = 1 if ($val == 2); $result = 3 if ($val == 3); } elsif ($result == 1) { $result = 2 if ($val == 2); $result = 9 if ($val == 3); } elsif ($result == 3) { $result = 9 if ($val == 2); } } print "ONE PAIR" if ($result == 1); print "TWO PAIR" if ($result == 2); print "THREE CARD" if ($result == 3); print "FULL HOUSE" if ($result == 9); print "NO HAND" if ($result == 0); print "\n";