11 lines
260 B
Text
11 lines
260 B
Text
F j(n, k)
|
||
V p = Array(0 .< n)
|
||
V i = 0
|
||
[Int] seq
|
||
L !p.empty
|
||
i = (i + k - 1) % p.len
|
||
seq.append(p.pop(i))
|
||
R "Prisoner killing order: #..\nSurvivor: #.".format(seq[0 .< (len)-1].join(‘, ’), seq.last)
|
||
|
||
print(j(5, 2))
|
||
print(j(41, 3))
|