VOOZH about

URL: https://www.geeksforgeeks.org/aptitude/puzzle-100-people-in-a-circle-with-gun-puzzle/

⇱ Puzzle | 100 people in a circle with sword - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Puzzle | 100 people in a circle with sword

Last Updated : 6 Jun, 2026

100 people standing in a circle in order 1 to 100. No. 1 has a sword. He kills the next person (i.e., No. 2) and gives the sword to the next (i.e., No. 3). All people do the same until only 1 survives. Which number survives at the last?

πŸ‘ frame_3147

Check if you were right - full answer with solution below.

Solution: 

Method 1: Logical / Intuitive Approach

  • If the number of people n is a power of 2, the first person will survive.
  • After each round, half the people are eliminated, and the person who started the game survives.
  • When n is not a power of 2:
  • Let 2m be the largest power of 2 less than n (100).
  • The formula for the survivor is : Survivor = 2 x (n - 2m) + 1

Apply for n = 100:

Largest power of 2 less than 100 is 64 (26).

Remaining people beyond 64 : 100βˆ’64 = 36.

Survivor: 2 Γ— (36) +1 = 73

Answer: 73

Method 2: Step-by-Step

  1. People numbered from 1 to 100.
  2. Eliminate every second person in each round until only one remains.

Round-wise elimination:

  • Round 1: Remove all even numbers β†’ remaining:
    Round 1: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99
  • Round 2: Remove every second β†’ remaining:
    Round 2: 1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97 
  • Round 3: Remove every second β†’ remaining:
    Round 3: 1, 9, 17, 25, 33, 41, 49, 57, 65, 73, 81, 89, 97 
  • Round 4: Since they are in a circle, 97 killed 1, and in the last move, 89 killed 97, leaving us with these survivors.
    Round 4: 9, 25, 41, 57, 73, 89 
  • Round 5: Now, 9 eliminates 25, 41 eliminates 57, and 73 eliminates 89, leaving us with these survivors.
    Round 5: 9, 41, 73 
  • Round 6: Now, 9 eliminates 41, leaving 9 and 73. The next turn will be 73’s.
    Round 6: 9, 73 
  • Round 7: Now 73 eliminated 9 , And 73 is the Last Survivor.
    Round 7: 73 

Answer: 73

Method 3: 
Here, we can define an array with 100 elements with values from 1 to 100. 

  • Start with people numbered 1 to N in a circle; each person kills the next and passes the sword forward.
  • This eliminates every alternate person, leaving only odd-positioned people after each round.
  • The process repeats until only one person (the survivor) remains.

Step 1 : For a given value of N, find the "Power of 2" immediately smaller than N. Let’s call it P 
Step 2 : Subtract N from (P-1). Lets call it M, i.e, M = (P-1)- N 
Step 3 : Multiply M by 2. i.e M*2 
Step 4 : Subtract M*2 from P-1. Let's call it ans, i.e, ans = (P-1) - (M*2) 
So, the person with number "ans" will survive till last. 

Code:


Output
73
Comment
Article Tags:
Article Tags: