Problem 1277. How many days does the cat take to climb out of the hole?
A cat accidentally falls down a hole with sloping but rough sides. It can climb out of the hole of height h metres, but for every m metres it jumps, it falls back n metres where m is always bigger than n. It can only do one jump attempt per day and it is assumed that there is a small water source available to sustain it along the way.:) That said, how many days does it require to escape the hole?
NB: the cat must be clear of the hole or above it to escape so reaching exactly level with the hole opening it will still fall back down n metres.
HINT: once the cat is clear of the hole with its last jump it will not fall back into the hole.
EX: >> h = 20; m = 5; n = 3;
>> catdays(20,5,3)
ans = 9
Solution Stats
Problem Comments
-
4 Comments
My cat gets out 1 day earlier on cases 3 and 4, by a claw. He reaches 25 on day 20.
I stand by my test case answers for 3 and 4 as the cat must be clear or above the hole to escape.
Hi RIchard, sorry if my conditions are a bit restrictive and you are quite clever to have realised it could be a day earlier for those test cases. Perhaps my problem is unnecessarily restrictive so if others feel the same I will revise it. :)
There are also the feelings of the cat to consider--whether it is fair to force him to spend an extra day undergoing an experiment of questionable benefit to science (and no obvious benefit to cats).
Solution Comments
Show commentsProblem Recent Solvers77
Suggested Problems
-
Find the alphabetic word product
3326 Solvers
-
5602 Solvers
-
881 Solvers
-
Magic is simple (for beginners)
9203 Solvers
-
320 Solvers
More from this Author16
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!