Problem 4.7. Snow White is standing by the riverbank, and next to her are 7 dwarfs in the following order from left to right:

Jovial, Grumpy, Simple, Shy, Sleepy, Wise, and Sneezy.

A boat is rocking by the shore, capable of holding only 3 dwarfs and Snow White. Snow White is the only one who can row. Any two dwarfs standing next to each other in the initial line will quarrel if left unsupervised by Snow White. Snow White must transport all the dwarfs to the other side of the river without causing any quarrels. Mark all the dwarfs Snow White will take with her on the last trip.
Answer: Grumbler, Modest, Smartie.

Solution. Consider only the moment just before the very last trip. At this moment, Snow White and no more than 3 dwarfs are standing on the original shore, while at least 4 dwarfs are on the other shore. Since these at least 4 dwarfs are without Snow White's supervision and have not quarreled, none of them stood next to each other in the initial row. Therefore, these can only be Jolly, Simple, Sleepy, and Sneezy. Then, on the original shore with Snow White are Grumbler, Modest, and Smartie.

Finally, let's provide one possible algorithm for the crossing.