September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,20 @@
function Josephus(sequence prisoners, integer step, survivors)
integer n = length(prisoners), nn = n
integer p = 0
while n>survivors do
integer found = 0
while found!=step do
p = iff(p=nn?1:p+1)
found += prisoners[p]!=-1
end while
-- (if you want a kill list, build it here!)
prisoners[p] = -1
n -= 1
end while
return remove_all(-1,prisoners)
end function
?Josephus(tagset(5),2,1)
?Josephus(tagset(41),3,1)
?Josephus(tagset(41),3,3)
?Josephus({"Joe","Jack","William","John","James"},2,1)