Several crocodiles, dragons and snakes were left on an island. Animals were eating each other according to the following rules. Every day at the breakfast, each snake ate one dragon; at the lunch, each dragon ate one crocodile; and at the dinner, each crocodile ate one snake. On the Saturday after the dinner, only one crocodile and no snakes and dragons remained on the island. How many crocodiles, dragons and snakes were there on the Monday in the same week before the breakfast?
[snakes, dragons, crocodiles]
Monday before breakfast to Saturday after dinner is 6 full rounds of 3 meals.
[49, 86, 65][21, 37, 28] [9, 16, 12][4, 7, 5][2, 3, 2][1, 1, 1] [0, 0, 1]
If we started 30 days earlier, instead of 6, there would have been:
[30433357674, 53406819691, 40315615410]
I notice that the total number of animals is the same as the number of dragons on the previous day.
Also, the total number of animals drops by a factor of about 2.32 each day (as the numbers get larger)
-----------
def unchomp(alist):
a = alist[0]
b = alist[1]
c = alist[2]
a += c
c += b
b += a
return [a,b,c]
meals = 6
end = [0, 0, 1]
print(end)
for m in range(meals):
end = unchomp(end)
print(end)
------------ OUTPUT
[0, 0, 1]
[1, 1, 1]
[2, 3, 2]
[4, 7, 5]
[9, 16, 12]
[21, 37, 28]
[49, 86, 65]
I did not see this algorithm at first. I had a routine (which I called "chomp()", which checked many possibilities in order to end with a specific outcome. In every case I tried, there was only one solution to begin before 3 meals and end on a particular outcome. I had to see this pattern before finding the algo.
|
Posted by Larry
on 2024-06-11 08:57:05 |