Pages

Wednesday, 16 October 2019

Frog and Well Puzzle

Puzzle:
A frog is at the bottom of a 30 meter well. Each day he summons enough energy for one 3 meter leap up the well. Exhausted, he then hangs there for the rest of the day. At night, while he is asleep, he slips 2 meters backwards. How many days does it take him to escape from the well?
Puzzle Solution:
28 days
Day 1 – It jumps 3 meters. 0 + 3 = 3.
Then falls back 2 at night. 3 – 2 = 1
Day 2 – It jumps 3 meters. 1 + 3 = 4.
Then falls back 2 at night. 4 – 2 = 2.
Day 27 – It jumps 3 meters. 26 + 3 = 29.
Then falls back 2 at night. 29 – 2 = 27.
Day 28 – It jumps 3 meters. 27 + 3 = 30

No comments:

Post a Comment

Code Review

 SOLID Principles S – Single Responsibility Principle There should never be more than one reason for a class to change. O – Open-Closed Prin...