My code from reddit.com/r/dailyprogrammer