You are viewing a single comment's thread. Return to all comments →
More swift like solution
(1...n).forEach { value in print(String(repeating: " ", count: n - value) + String(repeating: "#", count: value)) }
or use reduce function
reduce
print((1...n).reduce(into: "") { result, value in result.append(String(repeating: " ", count: (n - value))) result.append(String(repeating: "#", count: value)) result.append("\n") })
I do not know about the complexity.
Staircase
You are viewing a single comment's thread. Return to all comments →
More swift like solution
or use
reduce
functionI do not know about the complexity.