There is a template for the chapter's practice. You can find my (maybe wrong) solution in solutions/ folder, but remember it will be more fun to try to solve them yourself.

Easy problems

Code 3.27

Medium problems

Hard problems

Code 3.28

Code 3.30