The Verbania project is nearing completion. The solution is nearly ready for implementation. As a highly valued member of the team, you alone have been selected to develop the Implementation….
How would you solve this dilemma?
The Elves-and-Goblins Problem
Try solving this problem. (The answer is at the end of the chapter.) As you may know, Elves and Goblins are mythical creatures. Imagine that three Elves and three Goblins all arrive at the right side of a riverbank, and they all want to cross to the left side. Fortunately, there is a boat. However, the boat is small, and it can hold only two creatures at one time. There is another problem. The three hostile-looking creatures at the bottom of this sketch are Goblins, and Goblins are vicious creatures. The three gentle-looking creatures are Elves. Here is the problem: Whenever there are more Goblins than Elves on one side of the river, the Goblins will immediately attack the Elves and gobble them up. Therefore, you must be absolutely certain that you never leave more Goblins than Elves on any riverbank. How would you solve this dilemma? (Please note that the Goblins, though vicious, can be trusted to bring the boat back!)