Simple exercise in Swift