## Interview Question

Financial Software Developer Interview

-New York, NY

Bloomberg L.P.## 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?

Tags:brain teaser, 12 1 day for rest 2 meters for sleep

AnswerAdd Tags

## Interview Answers

66 Answers

▲

36

▼

Never....the frog would be dead by day 10 since nothing to eat or drink.

HB on

▲

13

▼

Assuming it doesn't die of starvation, the answer is 28 days.* start of day 1 (0 days elapsed): 0m --> 3m (then falls back 2m by start of day 2) start of day 2 (1 day elapsed): 1m --> 4m start of day 3 (2 days elapsed): 2m --> 5m ... start of day 28 (27 days elapsed): 27m --> 30m start of day 29 (28 days elapsed): 28m --> 31m In other words, 28 days will have elapsed before the frog can jump to a height exceeding 30m.* * This answer assumes the frog is not able to walk away after it hits 30m. I would assume it has no energy left to climb out based on the problem description. If the questioner disagrees with this assumption, then the answer is 27 days.

Paul on

▲

13

▼

I agree -- it's 28...because on that morning, he'll be at 27 metres and he can jump to the top in one bound.

Rebecca on

▲

5

▼

28. Each night he ends up/starts the next morning at the number of days he's been there (first night, he's at 1 foot, 2nd night he's at two feet). Hence, on the 28th day he jumps 3 feet to 30 feet.

jmv227 on

▲

3

▼

It is 28 assuming reaching 30 ft gets him out of the well, people saying 27 are making the error of assuming there is a day zero, when counting days as with years there is no 0.

menelmacar18 on

▲

3

▼

Answer: Day 29 Remember that on Day 1 the frog ends at 1 meter, Day 2 the frog ends at 2 meters, ... So on Day 27, the frog end at 27 meters. On Day 28, the frog goes up to 30 meters, then back down to 28 meters. On Day 29 the frog finally makes it to 31 meters (out of the well). This will help if you are still not convinced: int height = 30; int curPos = 0; int days = 0; while(curPosheight){ break; } curPos -=2; if(curPos>height){ break; } } System.out.println(days); }

Anonymous on

▲

3

▼

Day 1: 0 + 3 = 3 - 2 = 1, D2: 1 + 3 = 4 -2 = 2, D3: 2 +3 = 5 - 2 = 3....D28: 27 + 3 = 30 -2 = 28, D29: 28 + 3 = Eaten by the bird that has been waiting for him....

AssMuncher on

▲

1

▼

28

satya on

▲

4

▼

Answer: 28 Each day he makes it up another meter, and then on the twenty seventh day he can leap three meters and climb out.

lana on

▲

1

▼

27th day

Madhu on

▲

2

▼

How did the frog get in the well in the first place? What is motivating him to get up? How does he know he can get out? If the frog slips two meters every night for 27 nights he will be very sad and wont try anymore so he will never get out. Wait....I am this frog!

BadHoodoo on

▲

2

▼

Thirty days as he is only moving one meter a day.

Anonymous on

▲

1

▼

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? Day 1: 3-2 = 1m Day 2: 4 - 2= 2m So on, so forth... It take the frog 30 days to get out of the 30 meter well.

Samantha Chisholm on

▲

0

▼

Because of the 3 meter jump per day, on day 27, starting at meter 27 + 3 meters = 30. No resting required on day 27.

27 on

▲

0

▼

27, on day 26 he will leap to 29 slide back to 27 so on day 27 he will be at the top

Rita Stone on

▲

0

▼

It'll take the frog 27 days to climb out of the well. The well is 30m, he can climb 3m/day but slides down to 1m/night. So, he only has accomplished 1m/day. On the 27th day, he will then be able to jump the 3m out of the well. *Frogs can go up to 3-4 weeks without food or water, so it would be pushing the limits on that. However, he's in a well and I'm sure there would be little insects in there for it to eat. Wells are also usually damp, so his back quarters will stay moist.*

Carrie Chance in Louisville, KY on

▲

0

▼

Every day there is 3 feet of effort, but only one foot of progress. On day 26 the frog jumps to 29 feet. Almost making it out. Just a foot away from the top. On the night of the 26th it slides down 2 feet. 29ft -2ft=27 feet, but it is still the 26th at night. On the 27th "day" the frog jumps up 3 feet. 27ft+3ft=30 feet. The top is 30 feet.

27 days to reach the "top"! on

▲

0

▼

d= number of days Y=d3-d2-3 27m=d(3-2) 27m/1=d

Jayne on

▲

0

▼

39

nnn on

▲

0

▼

Day 1 -> Total distance Covered = 3-2 = 1m Day 27 -> 1*27 = 27 Day 28 -> 27+3 = 30 and the frog and he escapes

Shravan Honade on

▲

0

▼

28 will be the final answer

Anonymous on

▲

0

▼

I agree with Rebecca. It's most likely to be 28

Subitha on

▲

0

▼

28 Days, provided Frog doesn't die Starving.

Rehan on

▲

0

▼

10

Cristian on

▲

0

▼

28, Do we play with blocks and get juice boxes latter?

Anonymous on

▲

0

▼

It would take the frog 30 days

Anonymous on

▲

0

▼

30 days

Mohammad Wamiq on

▲

0

▼

it has got to be 30 days, cause everyday he really only moves 1 meter, 1 meter everyday is 30 meters

aiden on

▲

0

▼

30

Anonymous on

▲

0

▼

30

Anonymous on

▲

0

▼

1 because he is in the hole until he isn't in the hole anymore. If his motivation was escape he wouldn't be sleeping and falling behind so much.

Matthew Seed on

▲

0

▼

30 days

Aaron Dooley on

▲

0

▼

28 days is the correct answer.

Taylor Ingles on

▲

0

▼

28 days is the correct answer.

Taylor Ingles on

▲

0

▼

I figure about 11 days, first day 3 meters and he slips to 1, the next day realizing that he slips each day he uses his sticky tongue and attaches it to something solid on the wall of the well, when he wakes in the morning he simply jumps another 3 meters, and continues this process until he can evacuate the well.

JJ on

▲

0

▼

27 to the rim, 28 1m out of the rim of the well.

Vanessa on

▲

6

▼

28

schubietxny on

▲

0

▼

28

Anonymous on

▲

1

▼

28 days. At start of day 27, he jumps 3m to reach the top of the 30m well but has no energy left to climb out. At start of day 28, he jumps another 3m and entirely out of the well.

lc on

▲

0

▼

If Mr. Frog manages to make it up the wall another meter everyday then, on the 27th day, he can leap three meters and climb out, the answer would be 28 days...

Deb Warren on

▲

0

▼

28 days. As the frog slips 2 meters down every night by the 27th day he has climbed 27 meters. On 28th, the frog will start from the point of 27m which means start climbing 3 meters foward and this way he reaches his 30m to get out.

NRT on

▲

0

▼

28. 27 days to get to go to sleep on level 27. Next day outa da hole.

JC on

▲

2

▼

27!! as he will be out on the same day. it will be 28 if he spends the night as well. and c'mon, frog is not based on a binary system, that he wont have enough energy after the last 3 meter, he sure will be motivated enough to take the 3.000001 meteres on the last day to get out of the damn well.

Waqas on

▲

0

▼

27 days

Shantanu on

▲

0

▼

28

Anonymous on

▲

0

▼

ITS ONLY 10 DAYS. Because, if he waits 10 days, he will summon the strength to jump 30 meters in one jump to the top of the well. Ya'll can't think outside the box...

Anonymous on

▲

0

▼

28

area on

▲

0

▼

28

Anonymous on

▲

0

▼

I know this isn't the right answer but if u think VERY VERY logically, well, he doesn't.

Gb on

▲

0

▼

28

wale on

▲

0

▼

30 days

nithes on

▲

0

▼

Most frogs have to surface for air. After a short amount of time they will die without air unless they are in aerated water and can absorb through skin. So ask what species is the frog.

Mark on

▲

1

▼

28days NB - he does 3m/day, but the result in the next morning b4 his next jump is 1m jump the previous day In the morning of day 26 b4 he jump, he has 5m left...meaning he has done 25m for 25days. On day 26, he jumps 3m, leaving him wit 2m to go but cos he sinks 2m overnight, the4 his resulting meters to go is 4m On day 27, he jumps 3m and left with 1m but sinking 2m more means the resulting meters to go is 3m On day 28, he complete his 30m and walk out from the well victorious provided no predator in the well and he didnt die of starvation

innovation on

▲

0

▼

28 days...

Karan on

▲

4

▼

27 At day 0, he jumps to 3m. At day 27, he jumps to 30m and gets out.

NK on

▲

1

▼

No math necessary. Frog is dead after a few days.

VSBennett on

▲

3

▼

Saying 28 is too easy. What about the external (1) and internal factors (2): (1) there might be a heavy rain during the first night and the frog can easily float up or, ..., drown, at all; (2) the frog may decide it's sunday - let's have a rest and spare the energy for a bigger jump on the next day...

nic on

▲

0

▼

What kind of Frog is it? Is the well full of Water? My first thought is that the frog would not survive, Food and air seem the best bet for Frog-a-cide. Of course if the question is mathematical only in nature then you would have to follow the logic above x=number of days y=30 meters x+2=y x+2=30 x=28

Stoneyzatiger on

▲

1

▼

Answer: Day 28 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 26 - It jumps 3 meters. 25 + 3 = 28. Then falls back 2 at night. 28 - 2 = 26. 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 Note: Assume after the first leap that his hind legs are exactly three meters up the well. His hind legs must clear the well for him to escape.

Sreepada on

▲

0

▼

x = number of days A = 30 meters x+2 = A x + 2 = 30 x=28

LeonardoL on

▲

0

▼

Frog must travel 30m. Makes progress of 3 meters in the day and loses 2m at night with total progress of 1 meter per 24 hours. Taking the frog 30 full days, (Day and night) to escape.

3 steps foward, 2 step back. on

▲

14

▼

try to answer this question as seriously as u can

na on

▲

2

▼

It's 29 - on the 28th day he can leap 3 meters and hang at the top (but he can't climb higher & out), and on the 29th day he'll leap and be out of the well at 31 meters.

Craig on

▲

1

▼

27 ..... he will jump 3 meters this day to get out!!!

Doug on

▲

1

▼

The math certainly says 27, assuming he only needs to get to 30m to actually get out. its easy to forget that, as pointed out by Paul, he can jump at the beginning of the day, therefore he can reach 3 meters in 0 days. I like the out-of-the-box notions presented by HB and nic. Maybe croaking could get him some help from someone. Maybe he could get up in a well bucket. Why does he want to leave? -- maybe he has everything he needs there and is safe from predators. Why does he slip down? Can he stop that? I wonder what they're looking for in a question like that. I wonder if it really helps them choose good candidates. I wonder who's going to bother reading this.

Brian on

▲

7

▼

27 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 26 - It jumps 3 meters. 26 + 3 = 29. Then falls back 2 at night. 29 - 2 = 27. Day 27 - It jumps 3 meters. 27 + 3 = 30 This question is ambiguous whether if the frog is able to get out when it reaches the top or if it needs to exceed 30 meters to climb out.

Cycloid on

## Add Answers or Comments

To comment on this, Sign In or Sign Up.