Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Josephus-problem/Raku/josephus-problem.raku
Normal file
16
Task/Josephus-problem/Raku/josephus-problem.raku
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
sub Execute(@prisoner, $k) {
|
||||
until @prisoner == 1 {
|
||||
@prisoner.=rotate($k - 1);
|
||||
@prisoner.shift;
|
||||
}
|
||||
}
|
||||
|
||||
my @prisoner = ^41;
|
||||
Execute @prisoner, 3;
|
||||
say "Prisoner {@prisoner} survived.";
|
||||
|
||||
# We don't have to use numbers. Any list will do:
|
||||
|
||||
my @dalton = <Joe Jack William Averell Rantanplan>;
|
||||
Execute @dalton, 2;
|
||||
say "{@dalton} survived.";
|
||||
Loading…
Add table
Add a link
Reference in a new issue