Day 7: The Seven Eggs

Seven identical eggs are being put into a 15 × 1 15 \times 1 egg box. However no more than two eggs can be put in a row. For example, one possible arrangement is E-E----EE-E--EE.

How many possible arrangements are there for the eggs?

Note: The egg box always stays in the same orientation so reflections count.


The answer is 2304.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

4 solutions

Michael Ng
Dec 6, 2014

The condition means that we can only get groups of 1 1 and 2 2 consecutive eggs.

If the seven eggs were grouped 1 , 1 , 1 , 1 , 1 , 1 , 1 1, 1, 1, 1, 1, 1, 1 , then how many ways are there to arrange them? We can model an arrangement by its gaps between each group. There are 6 6 positive gaps and two non-negative gaps on either side. We also know that the total number of gaps is 15 7 = 8 15-7=8 . Now we add one to each non-negative gap to make them positive.

Now by 'stars and bars' we have 8 8 variables which total 10 10 , giving us ( 9 7 ) = 36 \binom{9}{7} =36 ways.

We continue similarly for 2 , 1 , 1 , 1 , 1 , 1 2, 1, 1, 1, 1, 1 ; we have ( 9 6 ) \binom{9}{6} ways. However then we can permute the twos and ones giving ( 9 6 ) × ( 6 1 ) = 504 \binom{9}{6} \times \binom{6}{1} =504 .

For two twos we get 1260 1260 ways and for three twos we get 504 504 ways, giving us a total of 2304 \boxed{2304} .

Laurent Shorts
Feb 10, 2017

For n n places and k k eggs, let S k ( n ) S_k(n) be the number of ways to do it. You can either:

  • start with no egg, so you have S k 1 ( n ) S_{k-1}(n) possibilities;
  • start with an egg, then no egg, so you have S k 2 ( n 1 ) S_{k-2}(n-1) possibilities;
  • start with two eggs, then no egg, so you have S k 3 ( n 2 ) S_{k-3}(n-2) possibilities.

This gives a recursive relation :

S k ( n ) = S k 1 ( n ) + S k 2 ( n 1 ) + S k 3 ( n 2 ) \boxed{S_k(n)=S_{k-1}(n)+S_{k-2}(n-1)+S_{k-3}(n-2)}

With S k ( 0 ) = 1 , k S_k(0)=1, \forall k , and S k ( n ) = 0 S_k(n)=0 when n > k n>k or n < 0 n<0 .

Easy to put in a program or in a spreadsheet:

# Python code
def S(n,k):
    if n == 0:
        return 1
    if n > k:
        return 0
    if n < 0:
        return 0
    return S(n,k-1) + S(n-1,k-2) + S(n-2,k-3)

print S(7,15)
>>> 2304
Abhishek Sinha
Dec 14, 2014

Let A ( n , k ) , B ( n , k ) , C ( n , k ) , D ( n , k ) A(n,k),B(n,k),C(n,k),D(n,k) denote the number of arrangements with k k eggs and n n egg-holders with last two places of the arrangements being _ _ , _ E , E _ \_\hspace{2pt} \_,\_ \hspace{2pt} E,E \hspace{2pt} \_ and E E E \hspace{2pt} E respectively. Here E E means an egg is present at a place and _ \_ means the place is empty.

Now for i 3 , j 1 i\geq 3, j\geq 1 we have the following recursive equations : A ( i , j ) = A ( i 1 , j ) + C ( i 1 , j ) B ( i , j ) = A ( i 1 , j 1 ) + C ( i 1 , j 1 ) C ( i , j ) = B ( i 1 , j ) + D ( i 1 , j ) D ( i , j ) = B ( i 1 , j 1 ) A(i,j)=A(i-1,j)+C(i-1,j)\\ B(i,j)=A(i-1,j-1)+C(i-1,j-1)\\ C(i,j)=B(i-1,j)+D(i-1,j)\\ D(i,j)=B(i-1,j-1) and the following boundary conditions : A ( 2 , 0 ) = B ( 2 , 1 ) = C ( 2 , 1 ) = D ( 2 , 2 ) = 1 A(2,0)=B(2,1)=C(2,1)=D(2,2)=1 apart from the above, we have A ( 2 , ) = B ( 2 , ) = C ( 2 , ) = D ( 2 , ) = 0 A(2,\cdot)=B(2,\cdot)=C(2,\cdot)=D(2,\cdot)=0 .

We also have A ( i , 0 ) = 1 , B ( i , 0 ) = C ( i , 0 ) = D ( i , 0 ) = 0 , i 2 A(i,0)=1, B(i,0)=C(i,0)=D(i,0)=0, \hspace{10pt}\forall i\geq 2 Hence the recursion is now fully specified. We need A ( 15 , 7 ) + B ( 15 , 7 ) + C ( 15 , 7 ) + D ( 15 , 7 ) = 2304 A(15,7)+B(15,7)+C(15,7)+D(15,7)=2304

Rachel Laubacher
Jan 11, 2018

There are 4 possible solution cases for the spaces between the eggs, and 4 possible main cases for egg distribution.

Solutions for spaces between the eggs 1. There are eggs at the end 2.The left end has no egg 3.The right end has no egg 4. Both ends have no egg.

The sum for spaces between eggs or egg pairs. is that of identical objects into distinct bins where the bins are not empty, to ensure that the separate cases for pairs hold for no eggs at end, the two cases of only one egg at the end, and that of both eggs at the end.

Checking the handy identities for binomial coefficients, this reduces too

Cases for eggs

  1. No pairs

There is only one possible combination 2. One pair There are 6!/(5!) or 6 combinations 3. Two pairs

There are 5!(3!*2!), or 10 combionations. 4. Three Pairs

There are 4!/(3!), or 4 combinations.

Multiply the above formula with the separate cases and sum.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...