24 May 2020
A puzzle from my nephews in Kolkata
Reeling under the lack of power, water supply and all that the devastating cyclone Amphan left behind, apparently my nephews hunkered down and started doing puzzles. They could not wait for power to come back – so that they could recharge their phones and send me this problem thru Whatsapp.
Good problem. About 2 years back, I had posted a similar version of the problem.
Answer to the problem has been posted here: http://www.rajibroy.com/?p=21430
This has been doing the rounds on WhatsApp groups. I got lazy and wrote a simple Java program for it. It satisfies the condition of working for any ‘n’ but is hit and trial
Santosh, I assume you just iterated till the last person was left. That would be a O(n) algorithm, right? This can be solved in programming with O(1) algorithm.
Yes. With constant time it’s just math on paper no need for computer. Your solution is elegant
Exactly. Glad you liked the problem. I will post some more soon. (My nephews are feeding me with lots of them).