A Mutable Log

A blog by Devendra Tewari


Project maintained by tewarid Hosted on GitHub Pages — Theme by mattgraham

Solving a Puzzle with JavaScript

I received the following puzzle from a school friend.

100 people are standing in a circle in an order of 1 to 100. Person number 1 has a sword. He kills the next person i.e. person number 2, and gives the sword to the next i.e. person number 3. This repeats until only 1 survives. What is the number of the survivor?

For a brute-force solution, head over to this page.