Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Josephus-problem/Nanoquery/josephus-problem.nanoquery
Normal file
16
Task/Josephus-problem/Nanoquery/josephus-problem.nanoquery
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
def j(n, k)
|
||||
p = list(range(0, n-1))
|
||||
i = 0
|
||||
seq = {}
|
||||
while len(p) > 0
|
||||
i = (i+k-1) % len(p)
|
||||
seq.append(p[i])
|
||||
p.remove(i)
|
||||
end
|
||||
sur = seq[len(seq) - 1]; seq.remove(len(seq) - 1)
|
||||
return format("Prisoner killing order: %s\nSurvivor: %d", seq, sur)
|
||||
end
|
||||
|
||||
println j(5,2)
|
||||
println
|
||||
println j(41,3)
|
||||
Loading…
Add table
Add a link
Reference in a new issue