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 swo | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

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 swo

4th Jun 2020, 5:45 PM
Rahul Kumar
Rahul Kumar - avatar
14 Answers
+ 2
The last one will survive, because when someone gives the sword to him, he couldn't kill the next person because he will be the only one left. Hope it helped.
4th Jun 2020, 5:48 PM
Nika
Nika - avatar
+ 2
First of All,no.1 kills no. 2 and gives the sword to no.3, who kills no.4. If you continue, you realize that all even numbers will be killed(yeah, including no.100). Wether you do that on a piece of paper or do the coding, marking each set of eliminated numbers with a particular symbol, you'll notice that the elimination process unveils a pattern.{which doesn't seem necessary to solve your problem (you might just find it interesting, or you might understand something bigger. lol.) } So at the end of the elimination process, you find out that the survivor here will be number 41. Now you just have to write the codes.. I might not be the best person to do that. But... I might be wrong.
6th Jun 2020, 2:15 PM
Jaeson
+ 1
No. 100
6th Jun 2020, 1:02 PM
Ethan Zhu
Ethan Zhu - avatar
0
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. Who will survive at the last?
4th Jun 2020, 5:46 PM
Rahul Kumar
Rahul Kumar - avatar
0
Please answer
4th Jun 2020, 5:46 PM
Rahul Kumar
Rahul Kumar - avatar
0
Nika please provide me proper Algo and if possible thn please write the code
4th Jun 2020, 5:50 PM
Rahul Kumar
Rahul Kumar - avatar
0
only the 1st person will survive, because it will keep looping and eliminating one person until it reached out to the first person
4th Jun 2020, 6:50 PM
Aliyu Yahaya Muhammad
4th Jun 2020, 5:51 PM
Rahul Kumar
Rahul Kumar - avatar
- 1
Mitali help
4th Jun 2020, 5:51 PM
Rahul Kumar
Rahul Kumar - avatar
4th Jun 2020, 5:51 PM
Rahul Kumar
Rahul Kumar - avatar
4th Jun 2020, 5:51 PM
Rahul Kumar
Rahul Kumar - avatar
- 1
Bro I attempted but can't be able to solve
4th Jun 2020, 5:55 PM
Rahul Kumar
Rahul Kumar - avatar
4th Jun 2020, 5:55 PM
Rahul Kumar
Rahul Kumar - avatar
- 1
Ethan Zhu but how?
6th Jun 2020, 1:24 PM
Rahul Kumar
Rahul Kumar - avatar