I was recently introduced to Kaperkar’s Constant.
It is quite magical. You take any four digit number , sort the digits from highest to lowest to create a new number , sort the digits from lowest to highest to get , and calculate and new number . You repeat this procedure enough times and you end up with .
I made a nifty implementation of that in Julia below.
Here is my attempt to solve the monkeys and coconuts problem. The story goes
that five sailors were stranded on an island and had decided to gather some
coconuts for their provisions. They put all the coconuts in one large pile and
went to sleep. One sailor got up and fearing that there could be problems when the
time to came to divide the pile, he divided the pile five ways and noticing that
he has an extra coconut, he gave it to a monkey, and then hid his stash. The other
four sailor repeated the same procedure. When they woke up they noticed that
they had a smaller pile and proceeded to divide into five equal piles, this time
around there were no extra coconut left for the monkey. So the question is: what was
the size of the original pile?
We will denote by as the size of the
pile after the th sailor has carried out his procedure. In this system
is original size of the pile. So following this procedure we then proceed as
It is important to note that for , also . Alternatively, we think of the reverse procedure and express the above as
Observing that has to be divisible by 4 and 5 (last equation in the first system and first equation in the second), one can brute force the solution(s) by the following Julia code:
Which results in
[2496,1996,1596,1276,1020] m=51, x₀= 3121 [14996,11996,9596,7676,6140] m=307, x₀= 18746 [27496,21996,17596,14076,11260] m=563, x₀= 34371 [39996,31996,25596,20476,16380] m=819, x₀= 49996
This corresponds nicely to the answers that were obtained by rigorous derivation in the video, however it shows how programming can easily find such solutions by brute force.
If one would like to avoid the negative or blue concocts suggested in the video and also preserve the monkey. Below is an alternative derivation. Working through the first system, one gets:
Realizing the has to be necessarily divisible by 5, we denote the final share that each sailor gets in the last division by . So our Diophantine equation becomes
It will have solutions at .
While attending a conference and hanging out with a college later in the day he recounted to me a nice mathematical puzzle that he learned while growing up in Algeria.
Three brothers were in a bind, they could not divide their father’s inheritance. Their father has left them with 17 camels and instructions that half of his camels should go to eldest son, a third to the second eldest, and a ninth to the youngest. Knowing that there is no point in having a fraction of camel, they wanted a solution that would be fair and yet that would result in no fractional division of camels. A passerby, seeing their predicament proposed to help.
In order to resolve their problem he donated his camel to the pool of 17 camels, bring thus the total to 18. One brother will hence get 9 camels, the other would get 6, and the youngest would get 2 camels. But 9+6+2=17, therefore the passerby concluded that he would walk away with the left over camel. Problem solved… but how?
Two farmers decided to sit down and share their lunch food. One farmer had on him five loafs of bread and the other had seven loafs. Just as they were about to start, a passerby asked if he could join them. The three sat down and they equally divided the twelve loafs amongst themselves. When they were done, the passerby give them twelve dirhams for the meal. The farmer who contributed five loafs proposed that a fair division of that amount would be for him to take five dirhams and for the other farmer to take the remaining seven. A disagreement ensued. They sought the assistance of judge to resolve their disupte and his resolution was that the farmer who contributed five loafs should only walk away with three dirhams, while the other should have the remaining nine dirhams. How is this fair?