Skip to content

Instantly share code, notes, and snippets.

@LastOfTheCarelessMen
Created July 7, 2009 18:29
use p6;
sub payback($dice)
{
given $dice
{
when $_ <= 50 { 0.0 }
when $_ <= 66 { 1.0 }
when $_ <= 75 { 1.5 }
when $_ <= 99 { 2.0 }
when $_ == 100 { 3.0 }
}
}
sub MAIN($bet, $plays)
{
my $money = $bet * ([+] map { payback(int(rand() * 100)+1) }, ^$plays);
say "{$bet * $plays}\$ became $money\$ after $plays plays:
You get {$money / ($bet * $plays)}\$ for a dollar";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment