Cleaned upproblem 1 in ruby