Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,21 @@
killingCycle[prisonerCount,killStep = 2] :=
{
i = 0
killed = new array
prisoners = array[0 to prisonerCount - 1]
while length[prisoners] > 1
{
i = (i + killStep - 1) mod length[prisoners]
killed.push[prisoners.remove[i]] // Remove the killed prisoner from the prisoners array and add it to the killed array.
}
killedResult = "Killed:"
for kill = killed // Loop through the killed array to format it nicely.
{
killedResult = killedResult + " " + kill
}
aliveResult = "Alive: " + prisoners@0 // Get the only item left in the array
return """$killedResult
$aliveResult"""
}
println[killingCycle[41,3]] // Enter in total number of prisoners and the number to skip each cycle