June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,20 @@
my $d5 = 1..5;
sub d5() { $d5.roll; } # 1d5
sub d7() {
my $flat = 21;
$flat = 5 * d5() - d5() until $flat < 21;
$flat % 7 + 1;
}
# Testing
my @dist;
my $n = 1_000_000;
my $expect = $n / 7;
loop ($_ = $n; $n; --$n) { @dist[d7()]++; }
say "Expect\t",$expect.fmt("%.3f");
for @dist.kv -> $i, $v {
say "$i\t$v\t" ~ (($v - $expect)/$expect*100).fmt("%+.2f%%") if $v;
}

View file

@ -0,0 +1,22 @@
# Project : Seven-sided dice from five-sided dice
# Date : 2018/02/02
# Author : Gal Zsolt [~ CalmoSoft ~]
# Email : <calmosoft@gmail.com>
for n = 1 to 20
d = dice7()
see "" + d + " "
next
see nl
func dice7()
x = dice5() * 5 + dice5() - 6
if x > 20
return dice7()
ok
dc = x % 7 + 1
return dc
func dice5()
rnd = random(4) + 1
return rnd