Cody

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

51.49% Correct | 48.51% Incorrect
Last solution submitted on Aug 27, 2016

Problem Comments

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Join the 15-year community celebration.

Play games and win prizes!

Learn more