Submission for Reddit's /r/dailyprogrammer, intermediate #179