3
authorMart Lubbers <mart@martlubbers.net>
Thu, 3 Dec 2020 05:35:24 +0000 (06:35 +0100)
committerMart Lubbers <mart@martlubbers.net>
Thu, 3 Dec 2020 05:35:24 +0000 (06:35 +0100)
3/input [new file with mode: 0644]
3/one.icl [new file with mode: 0644]

diff --git a/3/input b/3/input
new file mode 100644 (file)
index 0000000..e3f8307
--- /dev/null
+++ b/3/input
@@ -0,0 +1,323 @@
+......#..........##......#.####
+.##...###....#.....#...#.#.....
+#..##..#.....#............#.#.#
+##.#....#####..#....#..#.#.....
+..#.#...##.##.......#.#..#..##.
+##.#.......#.#.#..#...#.#...#..
+...#...#..#.##....##..#.#......
+.......##.#.#.#.##...#.........
+..#...##.##...##..##.##...#....
+.#.#...#.....####..#.#...#.##..
+.#...#......##......##....#....
+..#.....#.........##.#...#.#...
+...#.#...#..##...#....#.....##.
+..#.....#..#..#......###.......
+...##.#....##..##...........#..
+....#......#..#....###...#.....
+.....#...#.#.....#..##........#
+....#...#....##.#.##.#...#..#.#
+.......##.#......##....#....#..
+...#.#...##..#...#..#..#..##.#.
+##.#...#..#..................##
+##........#....##...#..#..#....
+.#.#..............#######.##...
+##..#..#.#.##..#...............
+..#........#..#...##.......#...
+............##.##.#..........##
+.....##..#.....##..#.....#.....
+..#.##.###.#..##.............#.
+.........##...........#.....#..
+..#....#.#.###.#.#.......##....
+..###..##..#.#.##......#.#.##..
+##......#.#....##.#..#.#..#.#.#
+..##.#.###.#...#...............
+..####.......#...#.##....#.....
+..#....##...#.#.#.#....#.##..##
+.#...####..###....#.###...##...
+..#.#..........#.#..#..#.....##
+.#....#.........###...#.....##.
+..#.#.#.##........#.##.#.....#.
+#....#....###...#..#.........#.
+#..#.###....#..............#...
+............#....##.#......#.#.
+...#..#.####...............##..
+....##......#.#.........####..#
+.#....###..#.#..##........##...
+#..##.....###..#...............
+..#...........#........#...#..#
+......................#.#..#...
+.#.##.#..#.#....#...#...#.#....
+..#..#.........#..#.#..........
+.#......#####...#......#..#....
+..........#.....#..#.##.####.##
+##.##..#............#####...#.#
+..##..#..###......#...#...#....
+....#####........#.##...###....
+......#...##..#..#............#
+...#....##.##...#..#...#.......
+....#####.#...............###..
+.#....#..##....#.#.#..##.##...#
+...#..#..#........#.#####.....#
+......##.#...#..#..#.....#..###
+###.......#.#........#......#.#
+..#.#..#..#........#..#......#.
+...##.........#..........#.....
+...#..###.#.......#.#.........#
+....#..#.##...##.....#.....##..
+#.#.#.#.....##.##.###..#.#....#
+..#....#.....##.####..#........
+...#..#.##.....##.#..#....###..
+.#..#.....#....#...#.#.......##
+..#..#.......#.#.###......#.##.
+.###.####....##............##.#
+#....###.#......##.#......##.#.
+.##...........#.#....#.........
+#.##..##...#...........###....#
+#.#..#...#.#..#..###.#.##...#..
+..#...#.#..##....#..#..#.......
+#..##..#.####...#...#..####.##.
+###..#.##....#...#.###..##...##
+##..#..#.#....#.....##.......#.
+..#..##.##.#.......###.#.....#.
+..........#.####....#.......#..
+#...#.#..#.......##......##..##
+##...##.##..###...............#
+....##.#...#.......##...##..#..
+.#.........#...#.#...##.#.....#
+.#...#.#..#...#..##....#..#...#
+.#.#...#..#..###...##....#.....
+.........#.#...####..#...#.#...
+...#.............#.#..........#
+...#...#..##.#........#.#......
+...#...#.....#....#..###.##.###
+.#.#........#....#...#.###.#.#.
+##.....#.......#..##.#....#..##
+...###...#.#.#.#....#.#....#...
+#...#.#.......##.#..#....#.#...
+#...#......###.....###........#
+..#.##...##....#...#....#.#....
+#....#..###....##.#......##...#
+##.#...#..........#.##....#..#.
+.##....#............###.#...#..
+###.##.#####.##.....##..#####..
+..###.###.......#.#...#....#...
+.#...#....####.........#.......
+..##.#.#......#....#.#....#.#.#
+#.####.....#....#..#.....#.##..
+###.###.##...##.#.#.#.....#.#..
+.......#.....#.......##.#.....#
+#..#.##...#........#.#.......##
+#.#........#...#....#..........
+..#....##.#......#..#..........
+#....##.....#.....#.##.#...#...
+....#.#.....#....####...#.#.##.
+......#.......##...##.#......#.
+.#.........##...#..#..##..#....
+.#...##.....##.#....#..........
+....#.###..##..#...#..........#
+......#...#.#.#........##......
+.#..........#.#.....#..##..#.#.
+.......###.#......#....#.#..#..
+..##.......#....#....#.#...##.#
+#.##.#.......#..###..##...#.#..
+......####....#.#.....#...#..#.
+#.##.###..#..#.#.....###..#.#.#
+#.#.#..#.#..##...#...#..##.###.
+....##..##.#...............#.#.
+..###.#.#.##..#....##.......#..
+#.#....#..........##......#####
+.#.#.......##.#.#......##..#.#.
+......#.###.##.#..#....#.##....
+..###........#.......##.#.#....
+.#..##.............#.##.###...#
+.#####...#......#.......##.....
+##..###.#...#....#..#....#.#..#
+.#.........###.##.....##.....##
+.##.#....#..#.#..##..#....##...
+.#..#..#......###...#.......#..
+#.#...#.....#..#.#.#..#..###...
+....#....#..#..#....#..#.#.#...
+......#.......#.#.#.#.....#....
+###...#...#......#..#.#.#..#.#.
+#...##.##.##........##....#....
+.....#.......#...#...#.#.#....#
+...##.....##.#...#.#.#.#..#..#.
+.#.......##...........#...#.##.
+.##..........#......#.#...###..
+.....##...#.....#...#......#...
+...........#.....#..#...#..#.#.
+#.....##..#...........##....#..
+#.##...###.###....##..#..#....#
+#.#.##...##....###....##.##....
+.#..###.....#......#...#...#..#
+..#...#....#.#.###.#..#......#.
+......#.........#..#.##...#...#
+..#.#....##.#..##..##...#....#.
+#.....#....##.........##.#.....
+...#...#..###.###......##...###
+.##.###...##..#.##....##.#..#..
+..#..#.......#................#
+.....#..#.#.#..........##..#...
+......###.#.#............#..#.#
+..#.##.....##....#...#...#.#...
+..#......##...#...##........#..
+#.....#.....#..#......#.###...#
+....#..#.#.....#...#....#.#...#
+#.......#..#...##..#.#..#.##...
+..#......###...#.........##...#
+...#.......##.....#..##........
+.#....#.#.....##.#.#...........
+##..#..#...#.##.#.#.#.#.#..##.#
+##...####.#.#.##...#..#......#.
+#.##..####.##.#.........#...###
+#...#.......#.#..####.#.#.#....
+#....#........#........#.......
+..#..####.....#....##...###.##.
+...#.#..####.........#....#.##.
+##.#...#...#..#.#..##.....##...
+....#.........#.##........##.#.
+##...#......#....#..#....#....#
+###.....#......##...#...##...#.
+#.##...............#.......#...
+.##.#...#..#....#.#.....###..#.
+.....##...#.##.....##...#....#.
+#.#..#..........#####..##......
+..#.........##...#.........#.##
+...#..##.#.#..#......#..###.###
+#..#...#.#...##..........#.....
+.###..#....###.....#....#..###.
+#..#....#...#........##.....#..
+.#..###........#....#..####..##
+.#..#.#.#.......##.#..##.#..##.
+..#..###......##....#..#..#..#.
+.......###..##....#......#...##
+#........#.##.............##.#.
+...#.#.#....##....##.###...#...
+..#.....#..##..#.#.......#.####
+.#......##.........##...#.....#
+.#.###........##....###.#.#...#
+##...#.#....#.....##.......#..#
+#...........#...........####...
+#..#.#..##..#...#....#.##....#.
+................##.............
+..##...#.#....##....#...#......
+.#.....#....#....#..#..#.#..##.
+.....######.#.#.##.###.#.......
+..#####....#..#...........#.#..
+.......#..#..##.#...###.#.#.###
+###...#...#..##.#.##..#...#..#.
+.#..#..............#...........
+.#.....#.....##....#....##..#..
+....#####.#....#......#.......#
+.#.#.....##.####..#...#.......#
+.#...##.#.......#.....##.#..##.
+..........#...#....###....#...#
+..#......#...#...#..#.#........
+.......#.......#..####..##.....
+.#..#.....###...#...#...#...#..
+##..#.......#.#...#..#..#.##..#
+#..#...#.#.....#.##.#........#.
+......#......#.#..###.##..###..
+.#..#..#.##.#...........#...##.
+.#....#...#.#..#.#.#...##.#..#.
+##.#....#..#..#.#...#......#.#.
+..#.#............##...#........
+...####...#...#.....##..#...###
+....###.......###.##..#.###....
+#......#.#....#.#.##.#.##..###.
+.....##.....#..##.....##....#..
+..#...#..##.#.##.#.#.#.......##
+#....#..##.......#......#..#.##
+#.....##...#..##......##.#.#..#
+....#..##..#.##...#.#.##..#..##
+#..#...##....##..#...#....#...#
+.##.#.#....#.....#........##.#.
+..##..#....#........#.....#....
+.##.#..##...#.....#...###.....#
+#..#..#........#..#.....#.#.#.#
+..##..###.#..#...#.#......#..#.
+#.....#.....#.###......##..#.#.
+.........#...##.........#...#..
+.##.#.##......#.#...###..#....#
+...##.#..###........##......#..
+...#.#...#......#.#.#....#..#..
+..####.........#..#....#.......
+#..#.........##.#.##....#.....#
+..#..#..#.#........#.###.......
+##.#..#..#....#...##.......#..#
+..#.#.....#.............#...##.
+..........#...##.....#..#.#..#.
+....#..#...#..##..#...##.#.....
+##....#......#..#.....#..#.....
+...#.#.#.#...........##...#.#..
+....#.###...#............#.....
+.#.#.#.......#.#......#....#.#.
+#.#.#.#..##.#..#..##...##.#..#.
+.#.##....##..#........#....#...
+####...#....#.#...#..#..###...#
+.....#.#.##.......##..#.######.
+.......#.#.#.....#.#..##....#..
+..#....#.#..#.#.#..#..#........
+.....##......#.........#.#...##
+#....##.#.....#..........#.#...
+#...#.#..#.#..#.#....#..#.#....
+....##........#................
+###.#.#...#..##...#...#.##...#.
+...#....###..#..##..#..#.......
+.....#..........#.#........##.#
+.#........#.##.#..##..#...#...#
+..##....#...#.#.........##.#...
+......#...#......#.....#.......
+....##.##..#.##...#.#.#.##.#.#.
+..#...#.....#.#....##.#........
+.#.#.......#.......###..#..#...
+#...#..#..#..##....#...#.....#.
+.#..####.##.....##.........#.#.
+#...###.......#...####..##.....
+#.##.#....#.#.##.......#...#...
+..#.......#.#.##.##..#...##....
+.#.......#.#..#.....#.....#.#..
+..#..#.......##.....#.#.....#.#
+#...###..#..#..##...#.....#..##
+......#................#.......
+..#.....##..#.......#...#...##.
+...##...####.#..#...#.......##.
+..#...#..#...#...#..#..#####...
+#..#...#....#....#...........#.
+..#.......#..#.##...##..###...#
+.#..#..#......##...#....#......
+...#..##....#..........#.....#.
+###...#.#......#.#.....#.....##
+#.#..#.....#........#.##.#.##..
+....#...#.....#..#.......#.#...
+#.#...##....#..#.....#...#.#.#.
+.#......#...##..#.......#......
+...#...#.#.#.###.#..#.#..#.....
+###...#..###.#...#..##...####..
+.#.#.#..#........#..#......#..#
+.#..#....#......#....#.#...#...
+.##..........###...##.....#.#..
+.#...#.#.##.##..###.#...#..###.
+......#......#......#.##......#
+..#.##..#.#..#....##..##...#...
+.#......#..#...##....#...#.....
+.#.....#.##..........#..#......
+###.#..#.##..#..##...#..#...#..
+#.....###........#.#..##.#.....
+.....#.......##.....##.....#.##
+...##.#......####....##........
+..#..#..#....#.##.....##.####..
+...#..#....#.#..#.#..#.#.#..#..
+#..........#....#.#.#.#...#..#.
+...####.##...#..#.......#.#..##
+#........#..#..................
+.#..#....#.#.#..#..........#...
+###...#....####....#......#..#.
+#.........####..#..#...........
+.....##..#..##.##.##.#..#.....#
+.#..#.#.##..#..#.#.#.##.###....
+......##......#...#.##....#..#.
+.#.#....#..#......#..#...###...
+.##...#......##...###...#.#...#
+.......#.#....#............#..#
+.#..##.#.######...#...#......#.
diff --git a/3/one.icl b/3/one.icl
new file mode 100644 (file)
index 0000000..cd566ea
--- /dev/null
+++ b/3/one.icl
@@ -0,0 +1,26 @@
+module one
+
+import StdEnv
+
+read :: *File -> [String]
+read f
+       # (l, f) = freadline f
+       | l.[size l - 1] <> '\n' = []
+       = [l % (0, size l - 2):read f]
+
+Start w
+       # (io, w) = stdio w
+       # ls = read io
+       = (one 0 ls, two ls)
+
+one :: Int [String] -> Int
+one _ [] = 0
+one i [x:xs] = if (x.[i rem size x] == '#') 1 0 + one (i+3) xs
+
+two :: [String] -> Int
+two ls = prod [slope right down 0 ls\\(right, down)<-[(1,1), (3,1), (5,1), (7,1), (1,2)]]
+
+slope :: Int Int Int [String] -> Int
+slope right down i [x:xs]
+       = (if (x.[i rem size x] == '#') 1 0) + slope right down (i + right) (drop (dec down) xs)
+slope _ _ _ [] = 0