A.1. The shortest I came up with    [Golfing]

When code golfing, it’s important to establish the constraints you’re supposed to respect. A looser interpretation of the rules may lead to a shorter solution, but you don’t want to end up with a class that works only with a specific use case. Let’s establish the boundaries of this exercise:

  • We want a Container class that fulfills the standard use case established in chapter 1 and repeated throughout the book.
  • This class must also respect the functional specifications laid out in chapter 1.
  • We don’t require anything else: no robustness, no performance constraints, and especially no readability.

In my solution, I represent a group of connected containers using a circular list, just like Speed2

Get Seriously Good Software now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.