Completed first challenge of /r/dailyprogrammer. Difficult.