Problem 4 with a working solution, but one that doesn't scale.
Problem 5. Probably overkill, but more elegant than brute-forcing it.