Nonoblock: Difference between revisions
Swift - use nested functions instead of class
(Added Swift solution) |
(Swift - use nested functions instead of class) |
||
Line 2,303:
<lang swift>import Foundation
let totalBlockSize = blocks
var count: Int▼
▲ private init(cells: Int, blocks: [Int]) {
positions = Array(repeating: 0, count: blocks.count)▼
}▼
▲ if cells < totalBlockSize + blocks.count - 1 {
▲ print("no solution")
▲ return
nb.solve(cells: cells, index: 0, totalBlockSize: totalBlockSize)▼
}
if index == blocks.count {
count += 1
Line 2,347 ⟶ 2,328:
}
var str = String(format: "%2d ", count)
var c = 0
Line 2,367 ⟶ 2,348:
print(str)
}
}
print()
print()
print()
print()
{{out}}
|