From: Mart Lubbers Date: Thu, 3 Dec 2020 05:35:24 +0000 (+0100) Subject: 3 X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=d8eab5b13fb6e02247db211c35c1fc46b7d5ce76;p=aoc20.git 3 --- diff --git a/3/input b/3/input new file mode 100644 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 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