15b slow version, do not use

This commit is contained in:
Max Nuding 2021-12-15 13:00:00 +01:00
parent f6fa8e6b6a
commit 07ac0b2fc5
Signed by: phlaym
GPG Key ID: A06651BAB6777237

View File

@ -49,6 +49,27 @@ class Day15: Runnable {
lastRow = parts.count - 1 lastRow = parts.count - 1
lastCol = (parts.first?.count ?? 0) - 1 lastCol = (parts.first?.count ?? 0) - 1
var tmpParts = parts
for (rowNum, row) in tmpParts.enumerated() {
let newRow = [Int](0...4).flatMap { cr in
row
.map { rv in cr + rv }
.map { $0 > 9 ? $0 - 9 : $0 }
}
parts[rowNum] = newRow
}
tmpParts = parts
for num in 1...4 {
for i in tmpParts.indices {
let tr = tmpParts[i]
let ntr = tr.map { $0 + num }.map { $0 > 9 ? $0 - 9 : $0 }
parts.append(ntr)
}
}
lastRow = parts.count - 1
lastCol = (parts.first?.count ?? 0) - 1
var unvisited = Set<Coord>() var unvisited = Set<Coord>()
// Distances to startNode // Distances to startNode