public
Created

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
murder = (howMany, bounce) ->
people = [0..howMany] # people from 0 to 40
for i in people
people[i] = 1
killed = Array()
count=0
for i in [1..howMany]
whichOne = i*bounce - howMany*count
count++ if whichOne> (howMany-bounce)
if people[whichOne] is 1
killed.push whichOne
people[whichOne] = 0;
 
for i in [0..howMany]
if people[i] is 1 then console.log i
 
output = ""
for i in killed
output += i+", "
console.log output
 
console.log "not killed:"
console.log killed[howMany-1]
murder(41,3)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.