Skip to content

Instantly share code, notes, and snippets.

@tadzik
Created September 28, 2010 13:44
Show Gist options
  • Save tadzik/601011 to your computer and use it in GitHub Desktop.
Save tadzik/601011 to your computer and use it in GitHub Desktop.
my @s=<♠ ♣ ♥ ♦>;my @r=2..10,<j q k a>;my %v=j=>10,:q(10),k=>10,a=>1|11;my @d=map {[$^a,$^b]},(@s X @r);@d.=pick(*);my @p=[],[];sub a(@c is rw){@c.unshift(@d.shift)};sub b(@c){my $v=@c.map({%v{.[1]}||.[1]}).reduce(*+*);$($v.grep({$_ <21}))||$v[0]};for @p {a($_);a($_);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