Sensei's Library, problem 147

Adapted from Beginner Exercise 147 · OpenContent License

All problems