Cosc 326 - Effective Programming
Etude 2 - Heads and Tails
Problem Description
This is a problem about rearranging certain items according to certain rules. You can use coins while simulating this problem.
Rules:
- you must always move two touching coins
- you must finish with all the coins touching in a horizontal line
- only horizontal moves are allowed
- you are not allowed to rotate the coins
Note: Any movement of coins is a move!
Task
1. Given four heads followed by four tails in a line, what is the minimum number of moves to alternate the heads and tails?
2. In a suitable notation, write down your solution.
See my solution below:
1. Answer: 4
2. Solution: (the bold letters are the ones to be moved)
HHHHTTTT
TTHHHHT__T
TTHH__THHT
T__HTHTHHT
THTHTHTH
