I've written the solution in Python. The first image is the code, and the second image is an example of me running it :)
8.8m questions
11.4m answers