Created
January 18, 2013 22:47
-
-
Save kovek/4569362 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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