Skip to content

Instantly share code, notes, and snippets.

Created Jan 18, 2013
What would you like to do?
murder = (howMany, bounce) ->
people = [0..howMany] # people from 0 to 40
for i in people
people[i] = 1
killed = Array()
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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment