Assingment 1 solution in Swift