working solution for 022414 reddit challenge