id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

gone_fishing


Here's another Car Talk Puzzler: TOM: Three guys go out fishing. They decide in advance that whatever they catch, they're going to divvy it up equally. So, they finish fishing for the day. They pull back into port, and they're going to sleep on the boat overnight. They're going to get up in the morning, divvy up the fish, and go home. In the middle of the night, however, one of the guys has a severe hemorrhoidal flare-up, and he's got to get to the drugstore right away to buy some stuff. RAY: Right. TOM: So, he goes to take his third of the fish, and he notices that the number that they caught is not divisible by three, unless he throws one of the fish overboard. So, he throws one of the fish overboard, takes his third and leaves. A few hours later, in the middle of the night, another guy wakes up with horrible stomach pains. He’s gotta have the Kaopectate. So he goes to take his third of the fish, and he notices, interestingly, the same thing -- he can't take a third unless he throws one fish overboard. He throws one fish overboard, takes his third, and goes home. Third guy gets up in the morning and figures the other guys are still sleeping. So he figures, “I'll just take my third, and I'll go. When they wake up, they can take their third.” However, he realizes that he can't take a third. It's not divisible by three. RAY: Sonja Henie's...! What are the chances of that? TOM: He throws one fish overboard, takes his third, and leaves. Question: What is the smallest number of fish by which this little scenario could have taken place? To change this from a Car Talk Puzzler to a CodingBat problem, we're asking not what the smallest number is for which this scenario holds, but rather we're asking you to right a function, gone_fishing(fish), that returns True if the scenario holds, and False if not.


gone_fishing(4) → False
gone_fishing(5) → False
gone_fishing(997) → True

...Save, Compile, Run (ctrl-enter)

def gone_fishing(fish):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Post-solution available

Copyright Nick Parlante 2017 - privacy