more debugging printouts

This commit is contained in:
2024-12-16 11:07:30 -08:00
parent d8eafaeb1c
commit f41564d8f1
4 changed files with 20 additions and 16 deletions

View File

@@ -58,8 +58,8 @@ struct Maze : CustomStringConvertible {
let s: [[String]] = walls.enumerated().map { i, r in
[String(format: "%3d ", i)] + r.map { $0 ? "██" : " " }
}
print(" " + (0..<w).map { " \($0 % 10)" }.joined())
return s.map { $0.joined() }.joined(separator: "\n")
return (" " + (0..<w).map { " \($0 % 10)" }.joined()) +
s.map { $0.joined() }.joined(separator: "\n")
}
init(fromFile f: String) throws {
let content = try String(contentsOfFile: f, encoding: .ascii)

View File

@@ -146,6 +146,7 @@ struct AoC {
static func main() throws {
let maze = try Maze(fromFile: CommandLine.arguments[1])
let (graph, pathPairs) = maze.graph()
print("maze: \(maze.w)x\(maze.h) intersections: \(graph.count)")
let visited = search(graph: graph, start: maze.start)
let minCost = maze.ends.compactMap { visited[$0] }.map { $0.0 }.min()!
print("minCost: \(minCost)")