dreadpiratepeter has asked for the wisdom of the Perl Monks concerning the following question:
Given a 5 element array of cards, each a string of the form 'RS', where 'R' is the rank (2..10,J,Q,K,A) and where 'S' is the suit ('H','D','S','C'), determine what is the best poker hand that can be made with them. It is not necessary to determine striations with in a hand type (i.e. straight is acceptable, rather than 10-high straight). An example hand would be ('2H','9C','8H','JD','9S')
use strict; use warnings; use List::Util qw(shuffle min max); use Data::Dumper; my @cards; foreach my $r (2..10,'J','Q','K','A') { foreach my $s (qw(H S D C)) { push @cards,"$r$s"; } } my @deck = shuffle @cards; my @hand = sort @deck[0..4]; @hand = @ARGV if @ARGV; print join(", ",@hand) . ": "; # your solution here, put answer in $hand # end print $hand;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Golf/Elegance: Poker Hands
by ikegami (Patriarch) on Jun 09, 2008 at 23:02 UTC | |
|
Re: Golf/Elegance: Poker Hands
by pc88mxer (Vicar) on Jun 10, 2008 at 04:46 UTC | |
|
Re: Golf/Elegance: Poker Hands
by dreadpiratepeter (Priest) on Jun 09, 2008 at 21:03 UTC |