Imaginarium from CS193p rewritten in Swift