RosettaCodeData/Task/Josephus-problem/Zkl/josephus-problem-1.zkl

10 lines
219 B
Text
Raw Permalink Normal View History

2017-09-23 10:01:46 +02:00
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]);
}