Win a copy of Kotlin in Action this week in the Kotlin forum!
programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering OS Languages Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# [easy] Frogs and Burt Bacharach.

David O'Meara
Rancher
Posts: 13459
Yes, I'm in a whimsical frame of mind. Stop me if you've heard this one:

(hopefully I have the numbers atleast plausible, I just made them up and ran a quick check)

There is a pond which has a radius of 1 meter. In the middle of the pond is a frog. It is not crazy. The frog can swim in the pond at 1 meter per second. It cannot move any faster due to any other effects.

Circling the pond trying to catch the frog is Burt Bacharach. Why? No idea. Burt can circle the pond at 2 meters per second.

It should be clear that if the frog heads for any point on the edge of the pond, Bert can get there first. If the frog can get to the edge first, Burt will sing "Raindrops Keep Falling on My Head". How does the frog win and get his song?

Ryan McGuire
Ranch Hand
Posts: 1142
9
Umm... am I missing something? Can't the frog just swim for the shore directly opposite Burt? It should take the frog 1 sec to cover that 1m radius. Burt, on the other hand, has to cover PI * 1m at 2 m/sec, which would take him about 1.57 seconds.

Start singin', Burt.
[ November 29, 2005: Message edited by: Ryan McGuire ]

David O'Meara
Rancher
Posts: 13459
Oops, there's the mistake. Assume Bert can travel twice that speed. I'll chck the math still holds later. Sorry, it was after a beer or two

David O'Meara
Rancher
Posts: 13459
It should work with the new numbers, the answer I get is about 0.03s

Jim Yingst
Wanderer
Sheriff
Posts: 18671
The frog chooses a value r such that

(1 - π/4) < r < 1/4

i.e. approximately

0.2146 < r < 0.25

The higher r is, the greater the safety margin he'll have (time difference between when he reaches shore band when Burt gets to the same spot) but the more time it will take to get to the shore. It's up to the frog how much time he wants to take. Anyway, pick a value of r. Move to a distance r from the center of the pond. Travel in an arc (centered on the center of the pond) until the center of the pond is directly between Burt and the frog. As long as r < .25, the frog can circle more quickly than Burt, so eventually he can be 180° opposite Burt. Once that is achieved, head straight for shore. As long as r > 1 - π/4, the frog can beat Burt.
[ November 30, 2005: Message edited by: Jim Yingst ]

Sameer Jamal
Ranch Hand
Posts: 1870
Hope that frog can understand you Jim.

 It is sorta covered in the JavaRanch Style Guide.