# Advent of Code, Day 3 # # Count the squares whose four corners all hold a tree. Each square is # found once, from its top-left tree and a side length, by checking the # other three corners. # # roc run day3.roc # # Note: Roc 0.1.0's default app platform exposes only Echo.line! (no file # I/O), so the puzzle input is embedded below as multiline \\ lines. # The puzzle input: 141 rows of 141 cells, trees as '#'. input = \\............................................................#......................#...#...#......#.......................................... \\#.............................................#.....#.........##..#.....#.................................................................... \\.#.......................#.#..............##.....#..#.........#..#..#........#...............#..............................#...............# \\.................#.............#.......................#...#....#.............#...#....................#..........##.....##.........#........ \\....................................................................................#...................................#.................... \\.....#..#.......#..............................#...........#......##....#................#...........#......#....#.....#....#.....#.#..#..... \\...#.#...........#...............#.................#...................#............#.........#.......#........#..#....#...#....#..#.#....... \\...#........#.....#....#.......#......#.#....#.#.............................##...#.................................#.................#....#. \\...................#.....................................................#.................................................................#. \\#..........#.....#.................##................#...........#.......#..#......#...............#..#...............#...................... \\..............#................................................#..##....#...........................................#...........#.........#.. \\.....................................................................#...................#...#.#..........##.......#......#............#..... \\.....#..........#.................................#.#.#............#............................................##........................... \\........#.........#.#.......#...........................................................#...#......................#..#...................... \\.#.............#......#..........##...#......#.....#......................................#...#...#.#.#...................................... \\..............#.......................#......#....#.........#............#..#.#.##...............#.#............##.........................#. \\...................#...............#.............#...........#......................................................#............#....#...... \\.................#.............#..............#.........#.....#.........#................#...........#..#...............##........#.......... \\...#.................................#...........................................#.....#..........................#..........#............... \\.............#................................#...............#.............#..#.......#.#................#................................#. \\...#....#........#........#...............#............#........#.............................#...#...............#.............#............ \\.....#.........#......#.#...#.......#..................................#.....................#............................................... \\...#..............#.......................#...................#.......#.............................................#..#........#.....#...... \\.........#........#.........#................#......#.......#.....#...#...#.........#...#..............#..#..........................#....... \\............................#.......................#....................#..#...#...........................#....#..................#.#...... \\................#...........................................#.......#.#.#.................................................................#.. \\............#.................#.....#................#......#..#.......................................#..##..............#.................. \\........#........................#.......................#............................#..................#..#.....................#.......... \\...................................#...........#...................#..#........#...#...........................#.#........................... \\............#......................................#............#..........................#............#......................#...........#. \\...#................#................##...............................#.#.............#....#..............#...#................#............. \\...#..............................#...................#.....#........#...................#.#...#...................#..................#...... \\...................#........#.....##.....#................#................#...#.........##.##........#..#..#.................#.............. \\....#......................................#.............#...............#.##.#............#............##..............#.................... \\..................................#..#...........#..#...........................#........................##...#.............................. \\...........................#............................................#...#........#.#..............#...#....#............................. \\.#.......#..#...#..............................#...................#..#.................................#.................................... \\........#.........#.........#....#......................#...#....#.#.....................#.......#.......#.............#....#.........##..... \\................#.........#...........##....#.....................#......#....#...#....#..................#.................................. \\........#......................#.....................#...........#.#....#...##....................#...........#.....#....................#..# \\#.#..#..................#...#..................................#........#......................#..#......##....#...............#....#........ \\.................................#.......#..#........#..#...##.......#............###...#................###...........##.......#............ \\..............................................#......#..............#.......................#.........#.......#..#........................... \\..#....................#............#...........#............#.............#.....................#.....#..................................... \\...............#.#.....#...........#................#..............#...............#...#..............................#...................... \\..............#..........#..............#...........#...............#....##.....#...#..#.....#....................#.........#..#....#........ \\....#..#...................#......#...#..........#.............##.....#.....#...#.#...#......#......#........................................ \\.#..#.......#.....................#.........#..............##.#.....................#........#....#..#...#..#...................#............ \\.......#...#........................#.#.#............................#...#..#...#..................#......#.....#.....................#.#.... \\...................................#..........#...................#.....#...#....#........#.................................................. \\#...............................................#....#..........#...#.........#...........#.#.#.............#.................#.......#...... \\..............................#.....#...#..................#.#..........................#....#..#....#....................................... \\........................................#...................................#.#...#...........##...........................................#. \\.#........#......#.#..................#............###...........#..#..#....#.#...........#.........#..#...#..#.............................. \\......................................#.....##.......#......#........#...#.............#.#.#.......##.....##....#.........#.................. \\#...................###......#....................#....#..#.#.....#...........#..................................#...............#.#....#.... \\........#....#.#..............#.....#.......................#..........#.......#....#.......................#..............#...........#..... \\.....#.......#............................#......##..........##............#......#......#..........................#..................#..... \\.....#....................#........#.........#......#...................#..#.....#...........#........#..#..#......#......#..........#....... \\.........#....##...................#.........#.......#.....#........#....#.............#.......#............#......##........#............... \\..#..........................#........#.....#....##........#......#...#...................#..#..........................#..........#....#.... \\................#......#.......#.......#...........#....#.............#......#......................#......#................................. \\..............#..#.#...............#.##........#.##....#......#...##.....#..#....#........#.#....#.....#.#......#.##..................#..#.#. \\...........#..#.#............#.............#..........#............#....#.......#...........#..#......#....#................................# \\..##................#..#.#...........##........#..#....#................#.....#.#.................#....##...................#..............#. \\........................#.....#..............#...#..#......#....#..#.#.......#..#.##.......#..............###......#...#.......#....#.......# \\.........#.#....#........................#.........#..#.#.#.....#..........#.............#.#.#...........#......#..............#....#.......# \\........#...............#............#...........#.....#.....#.........#.............#.................#.#...#...................#..#..#..... \\#...........#....#..........#......................#.................#.#....................................#..............#..#........#...#. \\........#...........#....#.....#..................##...#..............#.#....##..........#.....#.#.....#.......#..#......#....#.#.....#..#.#. \\.......#...................#...........#.....#.....#..#............................................................#.....................#... \\...........#....................................................#.....#..#............#....................................#....#.#.#........ \\.....#..............#........#.....#................................#..#.....#.#.........#..................................#.#.#..........#. \\............#..................#...###.......###....#........#.....#..#.......#..#..#..#.#......#..#...##.#......#........................... \\...................#............#.....#.........................#.#....#...#................#......................##...............#..#....# \\.......................#.................................###.#..........#........................#......##.#....................#.#...##.#... \\............................#.........#.......##..............................#.#................................#..#..........#...........#. \\...........#......#..............#.#....#..#....................#.#.........................#.#.........#................#................... \\............#.....#......#...........................#........................#.....#...#.............................#...................... \\.................................#.....#.....................................#................#...#............................#.#........... \\..............#...#...#....#.......#............#......#.#.....#......#.#.....#.....#......##..#.........#..#.......#........................ \\.....#.#......###................#..........#....#..#...................#.......#.....#....#.....#.................##......#................. \\.....#........#..........#.....#.....#.#.....##.....#...##.........#........##...#.#..#......##...............#.#........#......#.....#...... \\...........#.............#..#.#..............#...#..#........................#.#.....#..............................#........................ \\..............#................#..........#.....#....#................#.#...#.#.......#..##.......#......................................#... \\..........................#.......#.................#....................#.........#.##....#.#.....#...#.....#..#.............#.........#..#. \\....#....#........#.........#.....#..........#...........#...#.....#.#.......................#..#........#........#....#.##..........#...#... \\........#.........#.#.............##................##...#...............#......#........##..#..#......#.......##.......#.#..............#... \\.....#...#......#........#....#....#..#..#...........#......#.....#...........#.....#...#...#................................#............#.. \\...........................#..........................................#..........#........................................................... \\....................#.................#.........#......#..........#.............#......#......#..#..........#........................#....... \\............#.........#...#..#.......##..#.........#......#.##...#.#...................................#..................................... \\..#.........#.......#...#.........#.#..........#.#...................#..........#......#...#............................#...............#.... \\...#.#............................................#.....#..#.......................#.......#.........#....................................... \\........#............#..............#........#.#............#....#........#...............#.......#..............#................#.......... \\..................#.....#.#...........................#........................................................#.........#..............#...# \\..#.#.......................#............#..#.......#................#...............#.#...#..........................................#...... \\...#........#.#................................#.#........#..#.......#..........#.............#...........................#..........#.....#. \\...........#.....#..................#...#..#....#............#..#..#.......#...............#.#...#.....#.....................##.............. \\..............#.........................#..................#........#...................#........#........#........#...........#............. \\...............................#.............#.................#.#....#................#...#.....#...#................#...................... \\..#.............................................##.............#...#......................##.......#....#..#..............#.........#....#... \\....#.........................#....#......#.#...##...#.....#.......#....##...#...#....#...#..............##......#.....................#....# \\........#....#...........#....#...#..............#..##..................#...............#..............#.................................#... \\.................##......#.........#........#...#.........#.....#...#.......#.......#.....#...#......#...............#....................... \\...........#..#.................#....##..................#....#...#......................#..#............#.#......##................#....#... \\....#...................#...#..#..............#.................#..#.......#..#...........##.....#............#.....#............#....#...... \\..........................#......................#...#.....................#.............................................................#... \\.........#.#..#........#............#............#.##........##........................##....#........#...............#...#.....#....#....... \\.....##.......#...........#.#....#.......#...#...................................#.................#.......#..........#...................... \\...#...................##......................#..........#..........#..#...........#.#................................................#..... \\...............................#......................#...........#.......................#.....#...#.#..........#.#....#.................... \\...............#..........#...............#.....................#.....##.#................................................................... \\...........#.......#......................................#...#.................................................................#.#.......... \\.....#.#..#.....#..................................#.#...#....#.#.#....#...................#..#...#.........#............#.#.....#..........# \\...............................#.............#...........#...........#.......#...........#...............#.##......#.........#............... \\.....#.............#...................#............................#........................................................#............... \\..#......#.....#......................#................#...#.............#...#..............#...#.....#...................................... \\..............#....#.........#.................###.....................##.............#.......#.#......#...........#.............#........... \\.............................................................................................................#............................... \\.................#...........#.....#.........#..#...#...........#.#..#.......#............................#....................#............. \\#.................#.................##...........#............#...#.......................................................................... \\......#..#...#............#..#...............#..............#...............#..#......#.......#...........#.#......#.......#................# \\.....................................................#.....................#......................................#.......#.........#........ \\.............................#...................#....................#......................#......#............#..#.......................# \\.##...........#...#......#.......................#.............#...#...#...................#..........................#......#...#........... \\.............#........#..................................#......#.................#............#..#.................#.............##......... \\...........................................#....#........#...............#.............................#...#................................. \\..#................#....#....#........#.......#............#......................#.........#................................................ \\................#...#........#.................................................................#........#....#.....................##........ \\............#.....#................................#...............#.................#...........#......................#..............#..... \\...................................................#..#..............#....................#.......................##.#....................... \\....................................#.............................#.......##............#..##............................#...#....#.......... \\................#...#.....................#.#...................#........#...............#.................#........................#........ \\...................................#.......................#...........#.....#..............#.............................................#.. \\..#......................................................#................................................................................... \\#................................................................#.....#................#...#........#.............#.......................#. \\..#......................#..................#..#.#..................#...............##.....#................#..............#............#.... \\.#............#................#.#.....................#......................................#.#............................................ \\..................#................##........#...........#............#.##................#.......#........................#................. \\...#.................#............................#.....................#.....................#............#.....#........................... main! = |_| { rows = List.map(Str.split_on(input, "\n"), |row| Str.to_utf8(row)) height = List.len(rows) width = List.len(List.first(rows) ?? []) var $count = 0.U64 for r in 0..