Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
9
Task/Josephus-problem/Zkl/josephus-problem-1.zkl
Normal file
9
Task/Josephus-problem/Zkl/josephus-problem-1.zkl
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
fcn j(n,k){
|
||||
reg p=[0..n-1].walk().copy(), i=0, seq=L();
|
||||
while(p){
|
||||
i=(i+k-1)%p.len();
|
||||
seq.append(p.pop(i));
|
||||
}
|
||||
"Prisoner killing order: %s.\nSurvivor: %d"
|
||||
.fmt(seq[0,-1].concat(","),seq[-1]);
|
||||
}
|
||||
9
Task/Josephus-problem/Zkl/josephus-problem-2.zkl
Normal file
9
Task/Josephus-problem/Zkl/josephus-problem-2.zkl
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
fcn j2(n,k,m){
|
||||
reg p=[0..n-1].walk().copy(), i=0, seq=L();
|
||||
while(p.len()>m){
|
||||
i=(i+k-1)%p.len();
|
||||
seq.append(p.pop(i));
|
||||
}
|
||||
"Prisoner killing order: %s.\nSurvivors: [%s]"
|
||||
.fmt(seq.concat(","),p.concat(","))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue