Solution for 9.2 (including test case)