bit behind, so much work
This commit is contained in:
30
2020/3.js
Normal file
30
2020/3.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const fs = require('fs');
|
||||
const input = fs.readFileSync('3.txt').toString().split('\n');
|
||||
|
||||
function countTrees(lines, xoff, yoff)
|
||||
{
|
||||
let treeCount = 0;
|
||||
let length = lines[0].length - 1;
|
||||
let x = 0;
|
||||
|
||||
for (let i = 0; i < lines.length; i += yoff)
|
||||
{
|
||||
if (lines[i][x % length] == '#') treeCount++;
|
||||
x += xoff;
|
||||
}
|
||||
|
||||
return treeCount;
|
||||
}
|
||||
|
||||
let count = countTrees(input, 3, 1);
|
||||
console.log(`Part 1, tree count: ${count}`);
|
||||
|
||||
let total1 = countTrees(input, 1, 1);
|
||||
let total2 = countTrees(input, 3, 1);
|
||||
let total3 = countTrees(input, 5, 1);
|
||||
let total4 = countTrees(input, 7, 1);
|
||||
let total5 = countTrees(input, 1, 2);
|
||||
|
||||
console.log(`Part 2, tree count: ${total1 * total2 * total3 * total4 * total5}`);
|
||||
|
||||
|
||||
323
2020/3.txt
Normal file
323
2020/3.txt
Normal file
@@ -0,0 +1,323 @@
|
||||
.....##.#.....#........#....##.
|
||||
....#...#...#.#.......#........
|
||||
.....##.#......#.......#.......
|
||||
...##.........#...#............
|
||||
........#...#.......#.........#
|
||||
..........#......#..#....#....#
|
||||
..................#..#..#....##
|
||||
.....##...#..#..#..#..#.##.....
|
||||
..##.###....#.#.........#......
|
||||
#.......#......#......#....##..
|
||||
.....#..#.#.......#......#.....
|
||||
............#............#.....
|
||||
...#.#........#........#.#.##.#
|
||||
.#..#...#.....#....##..........
|
||||
##..........#...#...#..........
|
||||
...........#...###...#.......##
|
||||
.#..#............#........#....
|
||||
##.#..#.....#.......#.#.#......
|
||||
.##.....#....#.#.......#.##....
|
||||
..##...........#.......#..##.#.
|
||||
##...#.#........#..#...#...#..#
|
||||
.#..#........#.#.......#..#...#
|
||||
.##.##.##...#.#............##..
|
||||
..#.#..###......#..#......#....
|
||||
.#..#..#.##.#.##.#.#...........
|
||||
...#....#..#.#.#.........#..#..
|
||||
......#.#....##.##......#......
|
||||
#....#.##.##....#..#...........
|
||||
...#.#.#.#..#.#..#.#..#.##.....
|
||||
#.....#######.###.##.#.#.#.....
|
||||
..#.##.....##......#...#.......
|
||||
..#....#..#...##.#..#..#..#..#.
|
||||
.............#.##....#.........
|
||||
.#....#.##.....#...............
|
||||
.#............#....#...#.##....
|
||||
.#.....#.##.###.......#..#.....
|
||||
.#...#.........#.......#..#....
|
||||
..#.#..#.##.......##...........
|
||||
.....##..#..#..#..#.##..#.....#
|
||||
..##............##...#..#......
|
||||
...#..#....#..##.....##..#.#...
|
||||
#.....##....#.#.#...#...#..##.#
|
||||
#.#..#.........#.##.#...#.#.#..
|
||||
.....#.#....##....#............
|
||||
#.......#..#.....##..#...#...#.
|
||||
.....#.#...#...#..#......#.....
|
||||
..##....#.#.#.#.#..#...........
|
||||
##..#...#.........#......#...#.
|
||||
..#...#.#.#.#..#.#.##..##......
|
||||
#............###.....###.......
|
||||
..........#...#........###.....
|
||||
.......##...#...#...#........#.
|
||||
.#..#.##.#.....................
|
||||
.#..##........##.##...#.......#
|
||||
.......##......#.....#......#..
|
||||
.##.#.....#......#......#......
|
||||
#...##.#.#...#.#...............
|
||||
........#..#...#.##.......#....
|
||||
...................#...#...##..
|
||||
...#...#.........#.....#..#.#..
|
||||
.###..#........#..##.##..#.##..
|
||||
#...#.....#.....#.....#..#..#..
|
||||
###..#.....#.#.#.#......#....#.
|
||||
#........#....##.#...##........
|
||||
.#.#..##........##....##.#.#...
|
||||
#...#....#.###.#.#.........#...
|
||||
...#...##..###.......#.........
|
||||
......#....#..##..#.....#.#....
|
||||
........#...##...###......##...
|
||||
..........##.#.......##........
|
||||
...#....#......#...##.....#....
|
||||
###.#.....#.#..#..#....#...#..#
|
||||
.#.....#.#....#...............#
|
||||
..#....#....####....###....#.#.
|
||||
....##........#..#.##.#....#...
|
||||
.......##...#...#..#....####...
|
||||
#...##.#......##...#..#........
|
||||
..##..#.##....#.......##.#.#...
|
||||
..#.#...............#...#.#....
|
||||
....#.....#.#.....#.##.......#.
|
||||
...#.#..##.#.#..............##.
|
||||
..#.....#...#.............#.##.
|
||||
##..#.#...#........#..#.....##.
|
||||
...........##...#.#.###...#....
|
||||
...#.#.#..#..................#.
|
||||
.#...##.............#...#......
|
||||
..#..#...#.#.......#...#.....#.
|
||||
..##.......#.#.................
|
||||
.##..#........###.....#....#.##
|
||||
......#..###.......#....##....#
|
||||
....#.....#.................#..
|
||||
........#...#...#..............
|
||||
...#..#.###.......#..#.#.#.##..
|
||||
..#...#.....#....#.........#...
|
||||
...#.............#........###..
|
||||
......#..............#......#..
|
||||
#..#...........#...#..........#
|
||||
...##...#.###..#...#.....#.#...
|
||||
....#..##......#.......##......
|
||||
....#....##.#...#.#..#....#...#
|
||||
.#...........#..#....##...#..##
|
||||
..#.#.................###.#...#
|
||||
..#.#.#...##...........#.......
|
||||
..........#..##...#.#..##....##
|
||||
........#........#.##..#.#...#.
|
||||
.....#...##.......##......#...#
|
||||
....#...#..#..#.....#..........
|
||||
.#..#......#..#..#..###.......#
|
||||
.##..........#...#...#.#.....##
|
||||
..#..........#.#.#...###.......
|
||||
....#................#...##....
|
||||
.##..#....#..........#.#.#.....
|
||||
..##...#.#........#.....#.##...
|
||||
....####.....#..#.........##..#
|
||||
......#.........#...#..........
|
||||
....#...................#..##..
|
||||
.##....#.#.........#....#...#..
|
||||
....##...##.....#..####........
|
||||
..##.#....#.#.......##...#.....
|
||||
#...#.#.#...#..#..##.....#.....
|
||||
#..................###.....#...
|
||||
#.#.....#.......#.#...###.#....
|
||||
.#..#....#............#........
|
||||
#.#....#..#.#...............#..
|
||||
..#..#..#.............#......#.
|
||||
..#.......##...................
|
||||
.#....#.........#....#.#.#..#..
|
||||
....#....#..#...............#..
|
||||
......#..#..##......#.........#
|
||||
..#.##........##......#..#..#.#
|
||||
#.....#.#....#.........##...#..
|
||||
###..............#....###...##.
|
||||
....#..##......#.......##......
|
||||
......#...#.##......##....#..#.
|
||||
..........#....#..##.......#..#
|
||||
.#..#...##..#...........#..#..#
|
||||
.....#....#...#..###...###....#
|
||||
.#####..#...#.#.#..#.#.###...##
|
||||
..##............##.#...#.##...#
|
||||
.##..#...#...#....##.#..#..##..
|
||||
.#....#...#............##..#...
|
||||
.#.#......#....#....#..##..##..
|
||||
.........#...#.......#.##..#...
|
||||
#.........#.....##.....#..#..#.
|
||||
...##.#...#...#..#..#....##..##
|
||||
.#............#...#....##......
|
||||
..#...#.##.........#.#......#.#
|
||||
....#.##........#.........#..##
|
||||
#.........#......#.#......#..#.
|
||||
........#.#.......#.#........#.
|
||||
..#..........##.#...#..#.#.....
|
||||
..#...#....#...#...#..#.#..#.#.
|
||||
.#.........#....#..#####..#....
|
||||
#.#....#.#.###...#.............
|
||||
..##...........##......##......
|
||||
#.....#..#....#...............#
|
||||
...#.#..#....##......#...##....
|
||||
...#........#.....#...#..#.....
|
||||
.#......##.........#......#....
|
||||
..#..###.##...#.#.....#........
|
||||
.............#......#..#.......
|
||||
..#...............#.#...#..#..#
|
||||
.......#..#...#.#####......#..#
|
||||
.........#.....#...............
|
||||
##........#............#.#.....
|
||||
.#...#.....#..#..#...#....#...#
|
||||
..#....#....##......##.....#.#.
|
||||
#...##..##......#...#....#.....
|
||||
....#.#.#.....###....##.##....#
|
||||
..........##...##.......#......
|
||||
..#.......#...##.#....##.##....
|
||||
....#........................#.
|
||||
...#...#.#.##...#.....#...#..#.
|
||||
.#....##..#..#..........##..##.
|
||||
.#.....#..#...#.##.....#.......
|
||||
.#.##...#.#..#.....##....#...#.
|
||||
.##...#........##....#..#......
|
||||
.....#........#..........#.#..#
|
||||
....#..##.......#..#.....#.....
|
||||
...........#...#........#.##..#
|
||||
.....#..#....#..#.#.....#....##
|
||||
.....#....#.##.#..##...........
|
||||
...##.......##.........#.......
|
||||
...............##..#....#.#....
|
||||
.......###..#........#..####.##
|
||||
.......#.##...#.#....#.####....
|
||||
....#...............#..........
|
||||
##.#.......#.....#......#...#..
|
||||
......##.....#....#.....#..#..#
|
||||
.....#...##.............#......
|
||||
#.#.##.#.....#..#........#.....
|
||||
......##....#..#........#......
|
||||
............#........#..#.#....
|
||||
##.......#......#...####..#.##.
|
||||
..##..#...#.............#.##...
|
||||
.....#..##......#.##......###..
|
||||
............#........#........#
|
||||
#.#.#.#...#.#.....#.........#..
|
||||
.........#...............#.....
|
||||
.............###.#.......#....#
|
||||
###.##..#..#..........#....#...
|
||||
#......#...#..#..#.....#.##....
|
||||
............#....#....#..#.....
|
||||
..#.#....#...#......#.#..#..##.
|
||||
...#........................#..
|
||||
#.#...#..........#......#.#....
|
||||
.........#................#...#
|
||||
##.....#....#........##.......#
|
||||
#...##........#...#...........#
|
||||
...#...#..........##.......#.#.
|
||||
..#.#.#....#......##...........
|
||||
...#.#...#.##.#..#.#.##........
|
||||
#....##.....###..#.......#.....
|
||||
###.....#.#.#...#..#.........##
|
||||
..#......#..###...#.#.#.....#.#
|
||||
.#....#.....#............#..##.
|
||||
....#....##..........#.....##..
|
||||
#...........#....#...#..#...##.
|
||||
..#.......#.....#..........#...
|
||||
.#..#................#......#..
|
||||
..#......#.#...#..#.#....#....#
|
||||
...#..#...###..#..##....#.#....
|
||||
..#..............#.....#.......
|
||||
...#.#...#.........#.#.........
|
||||
##......##...........##.#.##..#
|
||||
..#..##..#....#.#......#.#...##
|
||||
...#.###....###...#.....#......
|
||||
#.#................#......#....
|
||||
..#.....#.....#....##.......#..
|
||||
.#.#...............##..#.......
|
||||
...#....#.......#.#.....##..#..
|
||||
.........#....#.......#.#...##.
|
||||
#....#......##.#.........##...#
|
||||
#.............#..##.#.#..##....
|
||||
...#....#..#...#....#.#.#.#...#
|
||||
.#....#....#..##.....#.#...###.
|
||||
##............#.#...##.#..#.#..
|
||||
##.#....##.....#..#..###....#..
|
||||
##....#................##......
|
||||
...##..#...#..###....#.....##..
|
||||
.#...##......#..#.#.....#...#..
|
||||
..##......##...#.##.......#....
|
||||
......#.....#.....##........#.#
|
||||
##....#...........#............
|
||||
#.......#....#..#.##..##.#..#..
|
||||
.#....##.#.....#..#..#.........
|
||||
.#....#.#.#...#.....##.....#.#.
|
||||
.......##.#.#........#......##.
|
||||
##........#.##.......#...#..#..
|
||||
...###..##....#.#....#.#.......
|
||||
......#.......#...##.....#...#.
|
||||
..#......##.#......#.....#.....
|
||||
.....#.....###...#.............
|
||||
#...#.#...#...#..#......#......
|
||||
#.....#.......###.#....###.#...
|
||||
...#.......#....####....##..#..
|
||||
#.#.....#....#........#.......#
|
||||
.........#.......#......#.#...#
|
||||
..##....#.....##...............
|
||||
..........#..#.#..#......#.....
|
||||
..................##...##.#....
|
||||
........#.......#...#..#.#.#...
|
||||
.....#.#..##..#..#.#..#.......#
|
||||
.....#........#..#..#....#....#
|
||||
##............#..#..#...#....#.
|
||||
.....#....................##..#
|
||||
........##.#....###............
|
||||
##.......#.##................#.
|
||||
.....###.#..#..#...#....###.##.
|
||||
.#......#.#....#.....##.#......
|
||||
...##......##.........#...#....
|
||||
....####..............#........
|
||||
#...#.#..##..##.........##.....
|
||||
......#......#....#..#.........
|
||||
#.....#.....#.##...............
|
||||
..#.##..#...##.#.####..#....###
|
||||
#..#......#....#.##..##...#.#..
|
||||
#....#.......#.....#.....#.#...
|
||||
##.......#.....##...#.....#....
|
||||
...#...##..........#..##..##..#
|
||||
.###..#..##...#....#...#..#....
|
||||
......##..###.......###...#....
|
||||
....#...#.#.......#.##...##..##
|
||||
#.#......#..##.#.#..#..#..#....
|
||||
......#........#.......#.......
|
||||
..........#.#.....##...........
|
||||
......#..#........#..#.#..###..
|
||||
##..#.............##..#........
|
||||
.........#....#.....#.........#
|
||||
.....#..##...#..#..##.##......#
|
||||
###..#...........#.......#....#
|
||||
...............#....#.#........
|
||||
.##.#...#.#........##....#.....
|
||||
.##.###...##..###....#...#...#.
|
||||
.##..#....#.#.#...#.#.#.#...#..
|
||||
.###.#...#.......#....#..#.....
|
||||
..#..#.#.#.#........#.....##...
|
||||
.#.......#.#...#.#...........##
|
||||
...#.....##....#.....##...#....
|
||||
................#.....####...#.
|
||||
.#.#......#.......##...#.##....
|
||||
.###.........#.#......#..#.#...
|
||||
#......#...#....#..##.......#..
|
||||
.##..#....#..#...........#...#.
|
||||
.#...#.......##........#.##....
|
||||
..#...........#...##...........
|
||||
.....##....##......#....#..#...
|
||||
#......#.#...#.##.#...##....#..
|
||||
#....................#...##...#
|
||||
..#............#........#......
|
||||
.............#.........##.....#
|
||||
...#...#......##.#...#...#.#...
|
||||
..#...#.#.................#....
|
||||
....##...#....#...###.##......#
|
||||
...#....#...#..#...#....#.....#
|
||||
...##.#........#..#.........#..
|
||||
..##.....#..##...#.....##...#..
|
||||
#.........#.#.#...#......#...#.
|
||||
#.#...........#...#..#..#..##..
|
||||
..#..#..##....#..........#.###.
|
||||
.....#..#....#.#...#...#..#..#.
|
||||
###.....#..#.................#.
|
||||
.#..##.##.#......#....##..#....
|
||||
15
2020/4.js
Normal file
15
2020/4.js
Normal file
@@ -0,0 +1,15 @@
|
||||
const fs = require('fs');
|
||||
const input = fs.readFileSync('4.txt').toString().split('\n');
|
||||
|
||||
const requiredFields = ['byr', 'iyr', 'eyr', 'hgt', 'hcl', 'ecl', 'pid'];
|
||||
|
||||
let currentPassport = {};
|
||||
for (const line of input)
|
||||
{
|
||||
console.log(input + '\nbruh')
|
||||
if (line == '')
|
||||
{
|
||||
console.log('new passport')
|
||||
currentPassport = {};
|
||||
}
|
||||
}
|
||||
1133
2020/4.txt
Normal file
1133
2020/4.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user