Welcome to NRICH.

 
Swapping buns investigation


By SUPER NERD on Sunday, November 28, 1999 - 09:58 pm:

A baker puts out a display of buns, he uses equal numbers of Bath buns (B) and Chelsea buns (C). He puts the buns in a row starting with a C, then a B, then a C, then a B and so on. He finishes with a B. In this example he uses three of each bun: C B C B C B
The bakers wife decides to put all of the B's to the right hand end of the display, she starts to do this by swapping any bun with its neighbour. she continues to do so until all the B's are on the right and all the C's are on the left.

1) Find a formula to calculate the number of swaps for any number of buns.

2) Investigate the number of swaps for different situations, make clear the conditions which apply to your chosen line of development.

Have fun!

SUPER NERD


By Neil Morrison (P1462) on Monday, November 29, 1999 - 06:44 pm:

The bun on the right edge doesn't have to move, the next one to the left has to move once, the next twice, the next three times etc.

for n B buns (numbered from right):
first doesn't move
second moves once
third moves 3×
...
(n-1)th moves (n-1) times
nth moves n times

minimum total moves: 1 + 2 + 3 + ... + (n-1) + n

minimum total moves: Sum (from k=1 to n) of k = n(n-1)/2

so for the illustration (3 B buns, n=3)

swaps = 3×2/2 = 3 swaps (which is true by inspection).