Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Foundation
- func drawSquare(_ n: Int) {
- let size = 2 * n + 1
- for i in 0..<size {
- for j in 0..<size {
- let distance = max(abs(n - i), abs(n - j))
- let number = 9 - distance
- print(number, terminator: "")
- }
- print()
- }
- }
- let input = 3
- drawSquare(input)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement