Family Day update

This commit is contained in:
Ingy döt Net 2020-02-17 23:21:07 -08:00
parent aac6731f2c
commit 9ad63ea473
2442 changed files with 39761 additions and 8255 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

View file

@ -5,6 +5,8 @@
* 09.05.2013 Walter Pachl accept arguments n w s and fix output
* thanks for the review/test
* I see no need for specifying a start count (actually a start number)
* This task states: n prisoners are standing on a circle,
* sequentially numbered from 0 to n-1. The 1st prisoner is 0.
* This program should work on EVERY REXX.
* Pls report if this is not the case and let us know what's a problem.
**********************************************************************/