Elves and macaroons

Dec 2019
52
1
ok
For their good work today, the five sneaky elves Charlie, Kim, Luca, Mika, and Ulli received big box with finitely many, whole, delicious coconut macaroons from Santa himself. Worn out from the exhausting day, they carry the box home and go to bed immediately while yawning loudly. Now, the box sits on the elves' kitchen table, where it is guarded by the elves' dog Anouk.

At 10:34 p.m., Charlie sneaks into the kitchen, gives a macaroon from the box to Anouk, divides the remaining macaroons into five equal parts (while not dividing a single macaroon), pouches one part, rearranges the residual four parts into a big pile, and returns to bed with a cunning grin on the face. At 11:56 p.m., Kim tiptoes into the kitchen, gives a macaroon from the box to Anouk, divides the remaining macaroons into five equal parts (without splitting single macaroons), puts one of theses parts into the pyjama pockets, shoves the other four parts into a pile, and slips off to bed looking very pleased. At 1:45 a.m., 3:17 a.m., and 4:23 a.m., Luca, Mika, and Ulli, respectively, repeat this procedure.

Despite the wakeful night, the elves are in a very good mood at 9:00 a.m. and meet for breakfast. They offer a breakfast macaroon to Anouk and split the remains of the coconut macaroons equally among themselves (again, dividing none of the single macaroons).

How many coconut macaroons does Kim at least get altogether?
 
Jun 2019
493
261
USA
I assume each elf is successful in splitting the pile they find (minus Anouk's part) into five piles of exactly the same number of whole macaroons (variation of a least common factor problem)?

I brute forced it instead of elegant method (factors), but...

Minimum original stack was N0 = 3121 macaroons.
Charlie gave one to Anouk, pocketed 624, and left N1 = 2496.
Kim gave one to Anouk, pocketed 499, and left N2 = 1996.
N3 = 1596.
N4 = 1276.
N5 = 1020.
They each then got 204.

So Kim pigged out on a minimum of 499+204 = 703 delicious coconut macaroons.

Gotta love that elven metabolism.
 

skipjack

Forum Staff
Dec 2006
21,321
2,386
This is a well-known problem, but you gave the wrong answer. There is an elegant way to solve this problem, but "factors" isn't a reasonable way of describing it.
 
Dec 2019
52
1
ok
I assume each elf is successful in splitting the pile they find (minus Anouk's part) into five piles of exactly the same number of whole macaroons (variation of a least common factor problem)?

I brute forced it instead of elegant method (factors), but...

Minimum original stack was N0 = 3121 macaroons.
Charlie gave one to Anouk, pocketed 624, and left N1 = 2496.
Kim gave one to Anouk, pocketed 499, and left N2 = 1996.
N3 = 1596.
N4 = 1276.
N5 = 1020.
They each then got 204.

So Kim pigged out on a minimum of 499+204 = 703 delicious coconut macaroons.

Gotta love that elven metabolism.
My teacher told me the answer starts with 35... so yeah that's not the right answer but thanks for trying to help
 
Dec 2019
52
1
ok
This is a well-known problem, but you gave the wrong answer. There is an elegant way to solve this problem, but "factors" isn't a reasonable way of describing it.
Do you know how to solve it?
 
Jun 2019
493
261
USA
OK, my start at the elegant approach was
$\displaystyle N_5 = \frac{4}{5} \left( \frac{4}{5} \left( \frac{4}{5} \left( \frac{4}{5} \left( \frac{4}{5} \left( N_0 -1 \right) -1 \right) -1 \right) -1 \right) -1 \right) \rightarrow N_0 = \frac{3125N_5 + 8404}{1024} = \frac{12500\varepsilon + 8404}{1024}$,where $\varepsilon \in \mathbb{Z}$ is the size of the smallest pile of cookies.
Find $a=8404 \mod 1024$ and $b=12500 \mod 1024$, and figure out how many $b$s you have to add to make the result an integer (i.e., $a + \varepsilon b \mod 1024 = 0$).
(I realise there are a lot of factors of two I could remove from the problem.)

Incidentally, here was my brute force method:
Code:
%Program Xmas cookies
%Start with N0 cookies.  Remove one, divide remaining into five equal
% integer stacks, steal one stack, remaining four stacks equal N1.
% Repeat for N2, N3, N4, N5.  Find N0.
clear; clc; close all

%Autonomous functions
fprev = @(Nnew) 1 + 1.25.*Nnew;     %N(n-1) as a function of N(n)
fnext = @(Nold) 0.8.*(Nold-1);      %N(n+1) as a function of N(n)
fN0 = @(N5) fprev(fprev(fprev(fprev(fprev(N5)))));  %N0 as a fn of N5
fN5 = @(N0) fnext(fnext(fnext(fnext(fnext(N0)))));  %N5 as a fn of N0

N0 = 6;
N5 = fN5(N0);
e = N5/4;           %Size of smallest stack
R = e - floor(e);   %Remainder of e

while R > 1e-10
    fprintf('N0 = %10i,  N5 = %16.5f\n',N0,N5)
    N0 = N0+1;
    N5 = fN5(N0);
    e = N5/4;
    R = e - floor(e);
end
fprintf('N0 = %10i,  N5 = %16.5f\n',N0,N5)

M = 5;
N = zeros(M+1,1);
N(1) = N0;
for n = 2:M+1
    N(n) = fnext(N(n-1));
end
disp([N floor((N-1).*0.2)])
 
Dec 2019
52
1
ok
OK, my start at the elegant approach was
$\displaystyle N_5 = \frac{4}{5} \left( \frac{4}{5} \left( \frac{4}{5} \left( \frac{4}{5} \left( \frac{4}{5} \left( N_0 -1 \right) -1 \right) -1 \right) -1 \right) -1 \right) \rightarrow N_0 = \frac{3125N_5 + 8404}{1024} = \frac{12500\varepsilon + 8404}{1024}$,where $\varepsilon \in \mathbb{Z}$ is the size of the smallest pile of cookies.
Find $a=8404 \mod 1024$ and $b=12500 \mod 1024$, and figure out how many $b$s you have to add to make the result an integer (i.e., $a + \varepsilon b \mod 1024 = 0$).
(I realise there are a lot of factors of two I could remove from the problem.)

Incidentally, here was my brute force method:
Code:
%Program Xmas cookies
%Start with N0 cookies.  Remove one, divide remaining into five equal
% integer stacks, steal one stack, remaining four stacks equal N1.
% Repeat for N2, N3, N4, N5.  Find N0.
clear; clc; close all

%Autonomous functions
fprev = @(Nnew) 1 + 1.25.*Nnew;     %N(n-1) as a function of N(n)
fnext = @(Nold) 0.8.*(Nold-1);      %N(n+1) as a function of N(n)
fN0 = @(N5) fprev(fprev(fprev(fprev(fprev(N5)))));  %N0 as a fn of N5
fN5 = @(N0) fnext(fnext(fnext(fnext(fnext(N0)))));  %N5 as a fn of N0

N0 = 6;
N5 = fN5(N0);
e = N5/4;           %Size of smallest stack
R = e - floor(e);   %Remainder of e

while R > 1e-10
    fprintf('N0 = %10i,  N5 = %16.5f\n',N0,N5)
    N0 = N0+1;
    N5 = fN5(N0);
    e = N5/4;
    R = e - floor(e);
end
fprintf('N0 = %10i,  N5 = %16.5f\n',N0,N5)

M = 5;
N = zeros(M+1,1);
N(1) = N0;
for n = 2:M+1
    N(n) = fnext(N(n-1));
end
disp([N floor((N-1).*0.2)])
How can I read the code? And does your answer start with 35?
 
Jun 2019
493
261
USA
How can you read the code? You start at the top left, go forward one character at a time until you hit the EoL, then jump to the next line...
It's a MATLAB code; perhaps that is a less facetious answer. Is that what you meant?

The output of this code was the N0 - N5, $\alpha$ - $\varepsilon$ values that I presented earlier, with a solution of $\beta+\varepsilon=499+204=703$, so no, it doesn't start with 35.
 

skipjack

Forum Staff
Dec 2006
21,321
2,386
However, the correct answer does start with 35.
 
Jun 2019
493
261
USA
$\displaystyle \left( 12+\frac{53}{256}\right) \varepsilon + \left( 8+\frac{53}{256}\right) \in\mathbb{Z}$, and 53 is prime, so $\varepsilon = 255 \rightarrow N_5 = 4\varepsilon=1020$
$N_4 = 5\varepsilon+1 = 1276 \rightarrow \delta = N_4/4 = 319$
$N_3 = 5\delta+1 = 1596 \rightarrow \gamma = N_3/4 = 399$
$N_2 = 5\gamma+1 = 1996 \rightarrow \beta = N_2/4 = 499$
$N_1 = 5\beta+1 = 2496 \rightarrow \alpha = N_1/4 = 624$
$N_0 = 5\alpha+1 = 3121$

Yeah, I got the same answer, so I'm totally stumped. If anyone wants to put me out of my misery, go ahead.
 
Similar Math Discussions Math Forum Date
Advanced Statistics
Similar threads
Placing Books on Shelves