Sensei's Library, problem 19

Adapted from Beginner Exercise 19 · OpenContent License

All problems