Brain Teasers
Not sure if software engineering is for you? If you enjoy solving complex problems then it just might be. Have a go at these brain teasers. Right or wrong, the important thing is that you relish having a go!
Puzzle 1 - Pool Table Balls
At the beginning of a game of English pool, 7 yellow balls, 7 red balls and a black ball are arranged in a triangle in the pattern shown below. A wooden frame, known as the rack, is used to get the balls into the triangle formation before the game can start.

Figure 1: Correct starting arrangement
Before the game begins you place the balls at random into the rack. You then need to rearrange them to the formation above before the game can start. For the purposes of this brain teaser you can only rearrange the balls by choosing one pair of balls at a time, and swapping their positions. This action constitutes a swap. No other actions, such as three way cyclic moves, are allowed.
- What is the maximum number of swaps you would ever need to make to get the balls from a random starting position into the formation shown above?
Many players also consider the inverse arrangement of red and yellow balls to be a perfectly valid starting arrangement. This is shown below.

Figure 2: Alternative 'inverse' starting arrangement
- What is the maximum number of swaps required to get from a random starting arrangement to either the ‘correct’ or the ‘alternative’ arrangement?
If you need it, here’s a hint!
Here's the solution!
Puzzle 2 - Flight Controller
You are the owner of a small airline and you need to create an efficient network of flight paths to allow for the airline to expand. The cities in your region are all quite small, and each has only one airport which can allocate you space for flights to at most three other cities. The airport authorities also insist that all routes operate in both directions. In addition, your customers find more than one layover on a flight is completely unacceptable. Therefore, from any one city you must be able to connect to any other city with at most two flights.
- Given these constraints, how many cities can your airline connect to?
- Describe the flight network, or draw a diagram showing the connections.
If you need it, here’s a hint!
Here's the solution!