Skip to content

Instantly share code, notes, and snippets.

@kovek
Created January 18, 2013 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kovek/4569362 to your computer and use it in GitHub Desktop.
Save kovek/4569362 to your computer and use it in GitHub Desktop.
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment