Welcome to MindCipher, a social repository of the world's greatest brain teasers, logic puzzles and mental challenges.

Survivor

There are 1500 people sitting around a circular table. They are numbered in a regular manner (1 to 1500 along the table).

Now, the 1st person gets a sword and kills the 2nd person. He then gives the sword to 3rd person, who then kills the 4th person and gives the sword to the 5th. This continues so that 1499th person kills the 1500th person and gives the sword back to 1st person.

Now the 1st person kills the 3rd and gives the sword to 5th person. This process continues until only one person remains. Which person remains?

Person #953

Hint: if the number of people is a power of 2, then the survivor is the first one (this is the difficult part to get).

Now, the power of 2 nearest to 1500 is 1024. 1500-1024=476. So after 476 people killed, the number of people remaining is a power of 2. 476th one who dies will be 476*2=952. Now the sword is with the 953rd one and he is the 1st one of remaining 1024 people. So the survivor will be 953rd one.

Comments


surya prakash singh

represent 1500 in binary 10111011100 take a circular left shift 01110111001 convert back into decimal ::: 953 //thats the answer ...simple

  

Dhumil Agarwal

@Surya: Can you please give a proof or explanation to your solution....Why did you take a circular left shift.?

  

Kranthi Krishna

@Agarwal Circular left shift does exactly what is described above Left shifting - (n-nearest power of 2)*2 Overflow will always be 1


Joshua

Similar to "Knights of the Round Table" problem.

  

Ravi

I knew it looked familiar!


nik

first find out the power of 2 nearest after 1500, then the ssurvivor will be=1500-(2048-1500-1) it can be understood by observing the pattern knights 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
survivor 1 1 3 1 3 5 7 1 3 5 7 9 11 13 15 1 3 5 7 the pattern is (2^n) knights -: 1 seat (2^n)-1 knights -: ((2^n)-1)-1 seat (2^n)-2 " -: ((2^n)-2)-2 seat . . . (2^(n-1)) knight -:1 seat i.e for n number of knights survivor is (n-((2^x)-n-1)) where 2^x is the power of 2 just after n


Abdulla Kaleem Abdul Ghafoor

//VARIABLE l1 is an array of numbers from 1-1500

$last = end($l1); while(count($l1)>1){

foreach($l1 as $a=> $b) { if($a%2 != 0)

unset($l1[$a]);

}

if($last == end($l1))       
unset($l1[0]);

    $l1 = array_values($l1);


foreach($l1 as $a=> $b)
    echo $b."\n";

echo "

"; $last = end($l1); }

  

Abdulla Kaleem Abdul Ghafoor

//VARIABLE l1 is an array of numbers from 1-1500

$last = end($l1);
while(count($l1)>1){

foreach($l1 as $a=> $b)
{
if($a%2 != 0)
unset($l1[$a]);

}


if($last == end($l1))       
unset($l1[0]);

    $l1 = array_values($l1);


foreach($l1 as $a=> $b)
    echo $b."\n";
echo "<br> <br>";
$last = end($l1);
}
Submitted by
Shaheen
over 4 years ago
Likes
Difficulty 8.5 ?

Tags
None

Back