Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
17
Task/Knuths-algorithm-S/Raku/knuths-algorithm-s.raku
Normal file
17
Task/Knuths-algorithm-S/Raku/knuths-algorithm-s.raku
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
sub s_of_n_creator($n) {
|
||||
my (@sample, $i);
|
||||
-> $item {
|
||||
if ++$i <= $n { @sample.push: $item }
|
||||
elsif $i.rand < $n { @sample[$n.rand] = $item }
|
||||
@sample
|
||||
}
|
||||
}
|
||||
|
||||
my @bin;
|
||||
for ^100000 {
|
||||
my &s_of_n = s_of_n_creator 3;
|
||||
sink .&s_of_n for ^9;
|
||||
@bin[$_]++ for s_of_n 9;
|
||||
}
|
||||
|
||||
say @bin;
|
||||
Loading…
Add table
Add a link
Reference in a new issue