Sharing cake: Solution


Which piece do you want?

Two people on a long walk sit down for a well-deserved break. Person A has brought along 3 cakes to eat and person B has brought along 5.

As they are just about to tuck in, person C arrives and asks to share their meal. A and B agree. They cut each cake into three equal pieces and each person eats one piece of each cake.

After the meal person C pays 8 coins for the cake. Person A gives B 5 of these coins and keeps 3. But person B complains. She demands to be given 7 of the coins with only 1 remaining for A.

Who is right and why?

Can you generalise the solution for an initial $k$ people having $n_1, n_2, ...,n_ k$ cakes respectively, who are then joined by another $m$ people who pay $n_1+n_2+n_3+...+n_ k$ coins each?

We'd like to thank Syed Abbas, Associate Professor and Chairperson SBS, IIT Mandi, India, for sending in this puzzle. Reportedly, a version of it was put to Ali ibn Abi Talib in the seventh century AD. Another version also appears in Fibonacci's famous Liber Abaci.


It turns out that Person B is right. After sharing each cake into three pieces there are a total of 8x3=24 pieces. They are divided equally between the three people, which mean that every person eats 8 pieces. To start with person A has 3x3=9 pieces and person B has 3x5=15 pieces. Out of his 9 pieces person A eats 8, which means that he has given away 1. Out of her 15 pieces person B eats 8, which means that she has given away 7 pieces. Therefore, person B should receive 7 coins and person A only 1.

Now for the general version of the problem. There are a total of

  \[ n_1+n_2+n_3+...+n_ k \]    

cakes which are each divided into $k+m$ pieces, which means there are

  \[ (n_1+n_2+n_3+...+n_ k)(k+m) \]    

pieces of cake in total. Each person eats

  \[ (n_1+n_2+n_3+...+n_ k) \]    


The $ith$ person, call them $k_ i$ brought along $n_ i$ cakes, so they initially have

  \[ (m+k)n_ i \]    

pieces. Since they eat

  \[ n_1+n_2+n_3+...+n_ k \]    

pieces themselves they should be paid

  \[ (m+k)n_ i-(n_1+n_2+n_3+...+n_ k) \]    


To double check, the total number coins received is

  $\displaystyle  $ $\displaystyle (m+k)n_1-(n_1+n_2+n_3+...+n_ k) $    
  $\displaystyle + $ $\displaystyle (m+k)n_2-(n_1+n_2+n_3+...+n_ k)+... $    
  $\displaystyle + $ $\displaystyle (m+k)n_ k-(n_1+n_2+n_3+...+n_ k) $    
  $\displaystyle = $ $\displaystyle (m+k)(n_1+n_2+n_3+...+n_ k)-k(n_1+n_2+n_3+...+n_ k) $    
  $\displaystyle = $ $\displaystyle m(n_1+n_2+n_3+...+n_ k),  $    

which equals the total number of coins that are being paid.