Maxwell interview question

Possible improvements to your code