more debugging printouts
This commit is contained in:
		| @@ -44,10 +44,13 @@ struct Map: CustomStringConvertible { | ||||
|         var s: [[String]] = Array( | ||||
|             repeating: Array(repeating: "  ", count: w*2), count: h | ||||
|         ) | ||||
|         walls.forEach { w in s[w.y][w.x] = "██" } | ||||
|         boxes.boxes.forEach { b in s[b.y][b.x] = "🮇🮀"; s[b.y][b.x+1] = "🮀▌" } | ||||
|         s[bot.y][bot.x] = "🮕🮕" | ||||
|         return s.map { row in row.joined() }.joined(separator: "\n") | ||||
|         walls.forEach { w in s[w.y][w.x] = "🮘🮘" } | ||||
|         boxes.boxes.forEach { b in s[b.y][b.x] = "🬴🬰"; s[b.y][b.x+1] = "🬰🬸" } | ||||
|         s[bot.y][bot.x] = "\u{001B}[91m🮿 \u{001B}[0m" | ||||
|         return ("    " + (0..<w).map { String(format: "%4d", $0 % 1000) }.joined() + "\n") + | ||||
|             s.enumerated().map { | ||||
|                 i, row in String(format: "%3d ", i) + row.joined() | ||||
|             }.joined(separator: "\n") | ||||
|     } | ||||
|     var gps: Int { return boxes.boxes.reduce(0) { s, box in s + box.gps } } | ||||
|  | ||||
| @@ -106,10 +109,11 @@ func readInput(_ filePath: String) throws -> (Map, [Move]) { | ||||
| } | ||||
|  | ||||
| var (map, moves) = try readInput(CommandLine.arguments[1]) | ||||
| print(map) | ||||
| print(moves) | ||||
| for move in moves { | ||||
|     print(map) | ||||
|     map.move(move) | ||||
|     print(move) | ||||
| } | ||||
| print(map) | ||||
| print(map.gps) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user