Solve AOC Day 3.2
This commit is contained in:
@@ -32,20 +32,37 @@
|
|||||||
(throw "parsePasswordCheck2 is broken"))
|
(throw "parsePasswordCheck2 is broken"))
|
||||||
|
|
||||||
// Day 3
|
// Day 3
|
||||||
(unless (= "..#.##.####" (Toboggan.pathString [
|
(deflocal exampleHillTile [
|
||||||
"..##......."
|
"..##......."
|
||||||
"#...#...#.."
|
"#...#...#.."
|
||||||
".#....#..#."
|
".#....#..#."
|
||||||
"..#.#...#.#"
|
"..#.#...#.#"
|
||||||
".#...##..#."
|
".#...##..#."
|
||||||
"..#.##....."
|
"..#.##....."
|
||||||
".#.#.#....#"
|
".#.#.#....#"
|
||||||
".#........#"
|
".#........#"
|
||||||
"#.##...#..."
|
"#.##...#..."
|
||||||
"#...##....#"
|
"#...##....#"
|
||||||
".#..#...#.#"] 0 0 3 1))
|
".#..#...#.#"])
|
||||||
|
(unless (= "..#.##.####" (Toboggan.pathString exampleHillTile 0 0 3 1))
|
||||||
|
(throw "Toboggan.path is broken"))
|
||||||
|
(unless (= 2 (Toboggan.pathTrees exampleHillTile 0 0 1 1))
|
||||||
|
(throw "Toboggan.path is broken"))
|
||||||
|
(unless (= 3 (Toboggan.pathTrees exampleHillTile 0 0 5 1))
|
||||||
|
(throw "Toboggan.path is broken"))
|
||||||
|
(unless (= 4 (Toboggan.pathTrees exampleHillTile 0 0 7 1))
|
||||||
|
(throw "Toboggan.path is broken"))
|
||||||
|
(unless (= 2 (Toboggan.pathTrees exampleHillTile 0 0 1 2))
|
||||||
(throw "Toboggan.path is broken"))
|
(throw "Toboggan.path is broken"))
|
||||||
(unless (= 289 (Util.countChar "#" (Toboggan.pathString (Util.readLines "src/year2020/inputs/day3-1.txt") 0 0 3 1)))
|
(unless (= 289 (Util.countChar "#" (Toboggan.pathString (Util.readLines "src/year2020/inputs/day3-1.txt") 0 0 3 1)))
|
||||||
|
(throw "Toboggan.path is broken"))
|
||||||
|
(unless (= 5522401584 (let [hillTile (Util.readLines "src/year2020/inputs/day3-1.txt")]
|
||||||
|
(*
|
||||||
|
(Toboggan.pathTrees hillTile 0 0 1 1)
|
||||||
|
(Toboggan.pathTrees hillTile 0 0 3 1)
|
||||||
|
(Toboggan.pathTrees hillTile 0 0 5 1)
|
||||||
|
(Toboggan.pathTrees hillTile 0 0 7 1)
|
||||||
|
(Toboggan.pathTrees hillTile 0 0 1 2))))
|
||||||
(throw "Toboggan.path is broken")))
|
(throw "Toboggan.path is broken")))
|
||||||
|
|
||||||
(defun :kiss.List<Int> pairWithSum [sum :kiss.List<Int> numbers]
|
(defun :kiss.List<Int> pairWithSum [sum :kiss.List<Int> numbers]
|
||||||
|
|||||||
@@ -4,3 +4,5 @@
|
|||||||
(.concat [(.charAt (nth hillTile y0) (Math.floor (% x0 .length (nth hillTile y0))))] (path hillTile (+ x0 dx) (+ y0 dy) dx dy))))
|
(.concat [(.charAt (nth hillTile y0) (Math.floor (% x0 .length (nth hillTile y0))))] (path hillTile (+ x0 dx) (+ y0 dy) dx dy))))
|
||||||
|
|
||||||
(defun pathString [:kiss.List<String> hillTile x0 y0 dx dy] (.join (path hillTile x0 y0 dx dy) ""))
|
(defun pathString [:kiss.List<String> hillTile x0 y0 dx dy] (.join (path hillTile x0 y0 dx dy) ""))
|
||||||
|
|
||||||
|
(defun pathTrees [:kiss.List<String> hillTile x0 y0 dx dy] (Util.countChar "#" (pathString hillTile x0 y0 dx dy)))
|
||||||
Reference in New Issue
Block a user