Skip to content
Snippets Groups Projects
Commit a2a55fc3 authored by La Fée Verte's avatar La Fée Verte
Browse files

adding the description`

parent 5bf9d660
No related merge requests found
#!/usr/bin/python3
running_count = [0,0,0,0,0]
def splitthem(quant):
"""
take a quantity and return False if it is not one more than
......@@ -11,6 +11,11 @@ def splitthem(quant):
if quant[0] % 5 != 1:
return False
else:
t = quant[0]//5
for k in range(5):
if running_count[k] == 0:
running_count[k] = t
break
quant[0] -= (1 + quant[0]//5)
return True
......@@ -29,6 +34,8 @@ def testnum(num):
return False
if num[0] % 5 == 0:
for i in range(5):
running_count[i] += num[0]//5
return True
else:
return False
......@@ -46,9 +53,17 @@ def main():
num = [0]
for n in range(1, TESTQUANTITY):
for i in range(5):
running_count[i] = 0
num[0] = n
if testnum(num):
print ("The Number Was %d" % n)
print (running_count)
total = 0
for i in running_count:
total += i
print (total)
return
print ("Not found in %d tries." % TESTQUANTITY)
......
Five guys get shipwrecked on a deserted island. They start off friendly and
spend the whole day collecting all the coconuts they can find. By the time it
gets dark they have gotten on each other's nerves to the point that they decide
to divey up their cocounts and go their separate ways. Since it has gotten
dark, they decide that they will sleep and take care of the details in the
morning.
A little while after they all go to bed, one of them wakes up and decides that
he doesn't trust the rest of them not to take all the coconuts for themselves
and leave him out cold. So he goes to the pile, meticulously separates the
coconuts into 5 perfectly equal piles and finds that there is one left over, so
he tosses that one to a local monkey who just happened to be watching him with
some curiousity. He then takes his fair 1/5 back to his bunk and squishes the
pile back together. Then he goes back to his bunk and goes to sleep.
By the time he falls back to sleep a second guy wakes up and has the same exact
concern. He executes the same separation on the pile that is left. When he
splits it into 5 piles, he also finds that there is one left over, and again
tosses the extra one to the monkey. Then he takes his fair 1/5, pushes the rest
of the pile back together stows his coconuts in his bunk and then he goes back
to sleep.
As you can guess, the next 3 guys all go through the same scenario, each of
them finding exactly 1 extra coconut to the delight of the waiting monkey. Each
take their fair 1/5 of the remaining coconuts and go back to sleep.
In the light of morning, none of them is going to admit to their nocturnal
excursions so they split the pile into 5 and amazingly, to the chagrin
of the monkey, there was no extra one this time. They each take their pile, and
the ones they collected during the night and went about their way never to be
seen again.
The puzzle is to determine what is the minimum possible number of coconuts that
they started with in the pile at the beginning of the night?
Extra credit if you can determine how many each of them ended up with?
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment