June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
16
Task/Josephus-problem/Perl-6/josephus-problem.pl6
Normal file
16
Task/Josephus-problem/Perl-6/josephus-problem.pl6
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