Interview puzzles with answers|100 people with sword puzzle

preview_player
Показать описание
100 Soldiers in a Circle Riddle : 100 people standing in a circle in an 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?
Рекомендации по теме
Комментарии
Автор

General solution could be : difference is increasing in power of 2.
Difference inc as 2^0, 2^1, 2^2, 2^3, 2^4, 2^5, 2^6 = 1, 2, 4, 8, 16, 32, 64.

Use A.P. concepts and write first and last element directly. After 6th round you will get the result.

amandubey
Автор

A sort of generalisation would be -
Convert the number into binary form, left rotate the binary and again convert to decimal
Binary of 100 => 1100100
After 1 left rotation => 1001001
Decimal of 1001001 => 73

TejasvaDhyani
Автор

General solution will be by taking number in binary form, taking its complement and subtracting with original number.
eg 100=1100100 its complement is 0011011 which is 27. Now 100-27=73

ankitkumar-fyom
Автор

You can convert the number to Binary representation. For example, if n=100:
then Binary representation of 100 = 1100100
take complement of the above number which will be = 11011 which is nothing but 27 in the decimal format.
If you subtract 27 from 100 it will be 73 which is the answer.
You can try this for any other value of n

manjun
Автор

It is a naive approach, everyone can do the calculation.

desi-memebaaz