Skip to content

Instantly share code, notes, and snippets.

@tadzik
Created September 28, 2010 12:29
Show Gist options
  • Save tadzik/600888 to your computer and use it in GitHub Desktop.
Save tadzik/600888 to your computer and use it in GitHub Desktop.
my @s=<♠ ♣ ♥ ♦>;my @r=2..10,<jack queen king ace>;my %v=:jack(10),:queen(10),:king(10),:ace(1|11);my @d=map {[$^s,$^r]},(@s X @r);@d.=pick(*);my @p=[],[];sub a(@c is rw){@c.unshift(@d.shift)};sub b(@c){my [email protected]({%v{.[1]}||.[1]}).reduce(*+*);$($v.grep({$_ <21}))||$v[0]};for @p {a($_);a($_)};for @p {say '-'x 33;loop {if b($_)>21 {say $_~' is over 21';last};say b($_);say ~$_;last if prompt('(h) hit (s) sit? ')~~'s';a($_)}};say "Winner: {[max]@p.grep({b($_) <=21})}";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment