diff --git a/2020/03/input.txt b/2020/03/input.txt new file mode 100644 index 0000000..22e0cd5 --- /dev/null +++ b/2020/03/input.txt @@ -0,0 +1,323 @@ +......##....#...#..#.#....#.... +.......#...#..#..#....##....... +#.#...#........###.#.##..#..... +.......#.....##.#..##...##.##.. +.#...#.#...##..........#..#.... +#.......##.....###.#...#......# +.........#....#.#.......#..#... +..#.......####.......###..##... +.#.#.##..#.#...##..#...###...## +...................#........... +....#.#.......#..........#.#..# +..#.#...........####.#.......#. +.....#.##..#..##..#.#...#...... +#.##...###..#................## +...#...#...#..##.#............# +#.##....##....#........#..#.... +..#......#.#.....##.......#.... +.......#......#....#......#.... +.#........##.....#.#...#...#.#. +..........##.#...#..#.......... +#####..##......#.....#......#.# +......#...............##...#... +..#.#.##..#...#.#........#...#. +..........#......#..........### +..#...##.##..##..........#..... +........#.##.#.....#..#...#.... +#.....#.........#.............. +..........##.##....#..#..#..... +..#...........#.......#........ +........#..#.....#.#.#...#..... +#.......##.....#.....#...#.##.. +###.#.#....#..#.....#........#. +..#..#..#..........#....#....#. +..#...##...#.#.##.....#..#..... +...#....###...........##.#..... +.##.................##.#....... +........#...#.##..#...#........ +.##..#............##..........# +............###.#....#..#...... +.....##....#.....#......#.....# +....#.....#.##.......#...#.#... +.##.#......#.........#...##.... +..##......#......#...........#. +.......#.#.............#....... +.##.#...#..##....##.......#.... +...#......##.#.#......#.....### +#.#....#.......#.#......#....#. +#......#.#.....#...........#..# +##.#..##...#........#.##.#....# +.....#........#........#...#... +...............#.......#..#.... +.#.#.#..#.#...#.......#.....##. +.#.#.............#..#....#..... +....#.......#..##.........###.. +.#.....#.#....#..#..#....#..... +........#......#.....#.#....#.. +##......#....##.....#.#..#.#... +.#...#..#.##.#.##.##.....#..... +#...#....#.........##.#....#... +.........##..#.....#..#...#.#.. +.#............#..........#.#... +...........#.....#......#.#.... +#...#...#.....#..#....#........ +#..##.....#..#.......#....#...# +#..#..#..........#......#...#.. +...#...#.#.##.#...#....#...##.. +......##....##....#....##..#### +...###.#..#....#.......#....... +#.........##......#...#........ +..........#....#.......#....... +#....##................##....## +.........#....#.#.......##.#... +.....#......###.......#..#...## +###.....#..##....###........... +.....#...#....#.....##......### +.#..#...#......##........##..#. +#.#.#.#....#.............#..... +......#.....##.#....#..##...#.. +..#............#.#....#..#...#. +.............#.#...##.......#.. +...#....#.##.#...#.#..##...###. +...#..............#.......#.... +......###.#............#.....#. +.##...###..#.####...#.......... +...#..#...#.#.#..#......#..#... +.#....##.###....#........#..... +..#..#....#.........##......... +..........##.###........#.#...# +.........#...#..#........#..... +.......#.....#...###........... +.....#.#..##......#...#...#.... +.....#....#..#........##.#..#.. +...#...........#............#.. +##.....#....#.#...#...#....##.. +...#.....#.....#...##...#...#.. +...##.#..........##...#.#.##.#. +....#.#.##.......#.#...#......# +......###...#....#.##........#. +.....#.........#...#...#..#..## +.........#................#.... +.##..###..................#.#.# +.##...........#...........#.... +#...#........#.....#..#...##... +.....#..#...#.........#.......# +..#..............#......#...... +#....#...............#.#....... +...#........#.#....#..#.###.##. +.......#..##..#...#..#...###... +..........##..#.......##.##.... +##.#..#.#...##..........#...... +.#.##.#...##.....#....#....#.## +...#.#......#...#.##..##....... +##.......#.#......#....##..#.#. +...#..#.##.........#...#.....#. +.##.##..##...#........#..#..... +.#.##.............#.#.#.....#.. +.......#.....................#. +......#...#....#..#..........#. +..#..#....#.#................#. +..#.....#..#.#......#......###. +...#...##..##....#..#...###.#.. +...#.....#............##......# +.......#.#.#......#.....###.... +.....#......#.....#.........#.# +#...#.#...#..#...#..#....#..... +#..##...#..##.............#..#. +##....##.......#.#.......#..#.# +..............#...#..#......#.. +..#...#...#.#...#.#............ +#..........#...#.............#. +..........##......#........#... +#...#...#....#.#...........#... +..#.#.#...##......#.#...#.#..#. +.......#.......#.............#. +.#..........#.................. +..##...#......#..........#....# +.#..##..........#...#.......... +...#....#..#.#.....##..##.#..#. +...#...#...#..#....##..#....#.. +..............#.#.....#......## +..............####....#.#..#... +.#........##....#...#.#...#..#. +.#..##.###....#.#.....##..#.... +...###.#.........#..#..#.##.#.. +.....#..#.....#..#...##......## +.#.#.##.............#...##..... +....##........#........#....... +.......#.....###..............# +#.##.......##....#.#.....#.#... +........#....#............#..## +...#.#..#.......#..........#... +..##....#..##......###.#.....#. +.#..#.#.##....#.......#........ +........#.####.#.......#.##.... +..........##...............#... +.#..#.....#....##..#..##...#..# +....#.#.....#.#.........#####.. +...#.##....#...###.##.#..#..... +.#...........#.............##.# +..#....#....####.....#.#....#.. +......##.......#....#..#....... +.####...##.#.#..#.####.#.#..... +###.........#..#.#.#.#........# +...#...#..#.............#.##... +.........#....#......#.....#.#. +...#....#......#..#......#....# +..#...#..........##..##........ +.....##........#......#.....#.. +...#....#....#....#..#....#.... +##...#...........##............ +.......#..##..#.......##.#..... +...............#.##.....#...... +#.#....##.#.....#...#.......... +........#......#...#......#.#.# +..#..#.....#.#........#........ +..####.....##.#.##.......#.#.#. +.#.##.#.......##......#.....#.. +....#.....##.........#.....#... +.#.#...###.#.#..........#....#. +.........##.#.#.....#..#....... +......#..#...#..#..###.#.#..... +.....#...#.#..#.#.......#.#...# +......##........#..#...#......# +#..##...#...#..#.....#..#..#..# +......#....#...........#.#..... +...#.......#...............#... +#.........#......#............. +..###..................#......# +#.....#.#.#.......##....#...... +.........#...........#....#.#.. +.###....##.##..##.............# +.##.#......#...#...##.......... +....#........###......#.#...... +...........#..#.##.#........... +.#..#.......#......#.#####..... +....##....##......#....#...#... +.......#..#.....#.#...###...#.# +..##.....#.......#.#.#..#.....# +.#...#............#....##...#.. +.#..#...##.......#............. +..##.......#...........#.#....# +...#.#...#....#..#.....#....... +...#........#...##...#.#..#.#.. +#........#..........#.......... +......#......#.........#....... +...##...#.....#.......#...#.##. +......##..##......#..###..#.... +....##....#..###.#.....##...... +##.##..#.....#..#.............. +..#.#..#....#....#....#.#...#.# +.#.....##.#.##.#..#.#.......... +...#......##.#...##..##...#.... +.###.....#......#.......#.....# +....##.......#.....#..#....#... +..........#..##....#..##.#....# +...#....#..##.#........#.#.#... +...#.#...#....#.......#..##.#.# +#..#..........#.#...#....#..... +#..#........................... +........#.....#.....#.#...#.#.. +#...#..#...#..........###...#.# +.....##.#..##.#.#.#.##....#.... +#.......#....#.#..#..#..#.#.... +..###.#.......#.#.##........... +#....#..#..........#.##..#.#... +..#..#........##....#..##...... +#...##..#.........#.#....#.#... +##..###..##...#.........#.#...# +###..#....#..##...#.#..#.#..... +.#.##.#......#............#.... +.#...#.##.#.........##......... +##.....###.....#........#..#... +...........##.#................ +.#......###......#....#..####.. +#...##.....#.....#..##....#.#.. +..#....#.......#.#.#......#...# +#.....#........#....#.#...#.... +..##...............#....#..###. +.#....#.......#..#...#......... +.##.#..#..#...#..#..#....#....# +.......#.#....#.....##...#..... +.#....#.#.#...........#........ +.........#..##..#..#...#....... +##..##...#......#.....#........ +#...........#.....#..###......# +.#...........#....#...#...##.#. +..............##.###.#.#####.## +........#.#...#.............##. +#...................###..#.##.. +#.....#...##................... +.....##..........#..#.#........ +.#....##.#....#....###....#...# +.......#.#...........#.#.....#. +......#........###...#...##.... +.##..........#..#..#........... +....#.......#..#.....##.#..#... +..#.##......#..#.....#..#...... +......#...#..##....#.#..#..#.#. +#.........................#...# +###.#.......#......##....#..#.. +..##.###.#...#.............#... +.....#...#...#......#....#####. +#..........#.#.##.#.#.....#..#. +....#.........#...#.#.........# +#.##.........#...#...#.####..## +.##.................#.......... +##.....#............#..#.#..... +#.#...#.#........#........#...# +.#...........#....#..#.......#. +.#.......#..........##..#.##..# +.#..##....#..##......#.#..##... +#......#............#.......#.# +.##...............#...#...#.... +.......##.#..#..##.....#....... +...#.......#..###.....#....#... +......#............#........... +####............#.........#.##. +#......#.#..#...#.....#..#..... +...........#...#..##.......#### +#.#...##..#....#.#.........#.#. +...#....#..#.......#.........#. +.........#.#.#...#....#........ +.#.....#........#..#.........#. +....#....#..#.....#...#........ +..#....#.#.....#..##........... +.#...#..#..#.##.###....#....... +#......##.......##..##......... +...#.........#.......##.#...... +.#...#...#.......#........##... +..#.............#.......#.....# +..#...........#.#.#...#.......# +.....##..#....#..............#. +#.#.....#.#.................... +.....#..##..#...#.....#........ +..#.......#..####..#....#.##.#. +#....#.....#.....#...#......#.. +..#....##...#....#..#..#.....#. +..#.####..............##....... +.#.........#..#...#.......##... +#....#.#........#....#...#...## +.....#..#....#.#..#...#.#.##... +.##.................#...##..... +.##.##.##...#...........#...##. +..#....#..#.....#..#......##... +.#...........#......#....#..#.# +.#.#............#..#..#...#.... +....#......#.....#.#.#.....#... +#.......##.............#....... +....#....................#.#... +......#........#..#.#.....#.#.. +.....#..#....#.#........#....#. +...##.........#...#.##....#..#. +.#....#..#...#.#.#......#...... +#......#.#.##.#..#..#.....##... +......#....#.#...#..#.#........ +..#.....##.....#...#.#.......#. +......#.#.....#........#....... +......#.#.#...#..#.#.#.#....... +..#.#.##..#..#..#.#.##...#..... +......#.#.#......#.....#...#... +.....#.##....#..##...#...#....# +..#.....#...........#..#..##... +..#..#.......#....#....###.#... \ No newline at end of file diff --git a/2020/03/part1.js b/2020/03/part1.js new file mode 100644 index 0000000..eedfb0a --- /dev/null +++ b/2020/03/part1.js @@ -0,0 +1,18 @@ +const fs = require('fs'); + +const data = fs.readFileSync('input.txt', 'utf-8'); +const lines = data.split('\n'); + +const width = lines[0].length + +// lets do it recursively why not +function trees(x, y, slopex, slopey) { + // escape case : bottom row + if (y >= lines.length - 1) { + return lines[y][x % width]=="#" + } + // haha javascript bool to int type casting go brrr + return (lines[y][x % width]=="#") + trees(x+slopex, y+slopey, slopex, slopey) +} + +console.log(trees(0,0,3,1)) \ No newline at end of file diff --git a/2020/03/part2.js b/2020/03/part2.js new file mode 100644 index 0000000..78e7f8d --- /dev/null +++ b/2020/03/part2.js @@ -0,0 +1,23 @@ +const fs = require('fs'); + +const data = fs.readFileSync('input.txt', 'utf-8'); +const lines = data.split('\n'); + +console.log() +const width = lines[0].length +// lets do it recursively why not +function trees(x, y, slopex, slopey) { + // escape case : bottom row + if (y >= lines.length - 1) { + return lines[y][x % width]=="#" + } + // haha javascript bool to int type casting go brrr + return (lines[y][x % width]=="#") + trees(x+slopex, y+slopey, slopex, slopey) +} + +// got lucky with this star lol +console.log(trees(0,0,1,1) +*trees(0,0,3,1) +*trees(0,0,5,1) +*trees(0,0,7,1) +*trees(0,0,1,2)) \ No newline at end of file diff --git a/README.md b/README.md index efad76f..f5a422d 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,20 @@ if (advent) { 11. [:star: :star:](https://adventofcode.com/2018/day/11 "see puzzle") 12. [:star: :star:](https://adventofcode.com/2018/day/12 "see puzzle") +#### [2019](https://adventofcode.com/2019 "2019 puzzle calendar") +1. [:star: :star:](https://adventofcode.com/2019/day/1 "see puzzle") +2. [:star: :star:](https://adventofcode.com/2019/day/2 "see puzzle") +3. [:star: :star:](https://adventofcode.com/2019/day/3 "see puzzle") +4. [:star: :star:](https://adventofcode.com/2019/day/4 "see puzzle") +5. [:star: :star:](https://adventofcode.com/2019/day/5 "see puzzle") +6. [:star: :star:](https://adventofcode.com/2019/day/6 "see puzzle") +7. [:star: :star:](https://adventofcode.com/2019/day/7 "see puzzle") + +#### [2020](https://adventofcode.com/2020 "2020 puzzle calendar") +1. [:star: :star:](https://adventofcode.com/2020/day/1 "see puzzle") +2. [:star: :star:](https://adventofcode.com/2020/day/2 "see puzzle") +3. [:star: :star:](https://adventofcode.com/2020/day/3 "see puzzle") + ## Languages Used * Python - py