Sensei's Library, problem 16

Adapted from Beginner Exercise 16 · OpenContent License

All problems