= Solution
The history is built by prepending, so reverse it when displaying chronological moves:
``
override def toString: String =
game.mkString("[", ", ", "]") +
" history of flips: " + flips.reverse.toString
``
Thus a reverse-stored history `[3,2,4]` is displayed as \b[`List(4, 2, 3)`]. The initial empty history remains `List()`. Neither traversal mutates the game or the immutable history. Displaying the stored list without reversing it would describe the moves backwards.
Back to article page