Skip to content

Commit

Permalink
day 11-23
Browse files Browse the repository at this point in the history
  • Loading branch information
CristiCeban committed Dec 23, 2023
1 parent 69ccba0 commit 47c7b9a
Show file tree
Hide file tree
Showing 39 changed files with 8,135 additions and 1 deletion.
122 changes: 122 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"private": true,
"dependencies": {
"axios": "^1.0.0",
"compute-lcm": "^1.1.2",
"js-sdsl": "^4.4.2",
"lodash": "^4.17.21",
"tslib": "^2.3.0"
},
Expand Down
25 changes: 25 additions & 0 deletions src/__tests__/day12.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { part1, part2, sumWithSpaces } from 'src/solutions/day12';

import { data12 } from '../data/data12';

const input = `#.#.### 1,1,3
.#...#....###. 1,1,3
.#.###.#.###### 1,3,1,6
####.#...#... 4,1,1
#....######..#####. 1,6,5
.###.##....# 3,2,1`;

describe('day 12', () => {
it('sumWithSpaces', () => {
expect(sumWithSpaces([1])).toBe(1);
expect(sumWithSpaces([1, 1, 3])).toBe(7);
});
it('part 1', () => {
expect(part1(input)).toEqual(6);
expect(part1(data12)).toEqual(7251);
});
it('part 2', () => {
expect(part2(input)).toEqual(6);
expect(part2(data12)).toEqual(2128386729962);
});
});
30 changes: 30 additions & 0 deletions src/__tests__/day13.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { part1, part2 } from 'src/solutions/day13';

import { data13 } from '../data/data13';

const input = `#.##..##.
..#.##.#.
##......#
##......#
..#.##.#.
..##..##.
#.#.##.#.
#...##..#
#....#..#
..##..###
#####.##.
#####.##.
..##..###
#....#..#`;

describe('day13', () => {
it('part1', () => {
expect(part1(input)).toEqual(405);
expect(part1(data13)).toEqual(35691);
});
it('part2', () => {
expect(part2(input)).toEqual(400);
expect(part2(data13)).toEqual(39037);
});
});
35 changes: 35 additions & 0 deletions src/__tests__/day14.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { fnv1aHash, parse, part1, part2 } from 'src/solutions/day14';

import { data14 } from '../data/data14';

const input = `O....#....
O.OO#....#
.....##...
OO.#O....O
.O.....O#.
O.#..O.#.#
..O..#O..O
.......O..
#....###..
#OO..#....`;

describe('day14', () => {
it('fnv1a', () => {
const parsed = parse(input);
expect(fnv1aHash(parsed)).toBe(1569778198);

const changeSingleChar = [
['.', ...parsed[0]!.slice(1)],
...parsed.slice(1),
];
expect(fnv1aHash(changeSingleChar)).toBe(3970664259);
});
it('part 1', () => {
expect(part1(input)).toEqual(136);
expect(part1(data14)).toEqual(108614);
});
it('part 2', () => {
expect(part2(input)).toEqual(64);
expect(part2(data14)).toEqual(96447);
});
});
16 changes: 16 additions & 0 deletions src/__tests__/day15.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { part1, part2 } from 'src/solutions/day15';

import { data15 } from '../data/data15';

const input = `rn=1,cm-,qp=3,cm=2,qp-,pc=4,ot=9,ab=5,pc-,pc=6,ot=7`;

describe('Day 15', () => {
it('part1', () => {
expect(part1(input)).toEqual(1320);
expect(part1(data15)).toEqual(509784);
});
it('part2', () => {
expect(part2(input)).toEqual(145);
expect(part2(data15)).toEqual(230197);
});
});
27 changes: 27 additions & 0 deletions src/__tests__/day16.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { part1, part2 } from 'src/solutions/day16';

import { data16 } from '../data/data16';

/* eslint-disable no-useless-escape */
const input = `.|...\....
|.-.\.....
.....|-...
........|.
..........
.........\
..../.\\..
.-.-/..|..
.|....-|.\
..//.|....`;

// long test, skipping it for others
describe.skip('Day 16', () => {
it('part 1', () => {
expect(part1(input)).toBe(46);
expect(part1(data16)).toBe(7623);
});
it('part 2', () => {
expect(part2(input)).toBe(51);
expect(part2(data16)).toBe(8244);
});
});
29 changes: 29 additions & 0 deletions src/__tests__/day17.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { part1, part2 } from 'src/solutions/day17';

import { data17 } from '../data/data17';

const input = `2413432311323
3215453535623
3255245654254
3446585845452
4546657867536
1438598798454
4457876987766
3637877979653
4654967986887
4564679986453
1224686865563
2546548887735
4322674655533`;

// long time to process
describe.skip('day 17', () => {
it('part1', () => {
expect(part1(input)).toEqual(102);
expect(part1(data17)).toEqual(755);
});
it('part2', () => {
expect(part2(input)).toEqual(94);
expect(part2(data17)).toEqual(879);
});
});
29 changes: 29 additions & 0 deletions src/__tests__/day18.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { part1, part2 } from 'src/solutions/day18';

import { data18 } from '../data/data18';

const input = `R 6 (#70c710)
D 5 (#0dc571)
L 2 (#5713f0)
D 2 (#d2c081)
R 2 (#59c680)
D 2 (#411b91)
L 5 (#8ceee2)
U 2 (#caa173)
L 1 (#1b58a2)
U 2 (#caa171)
R 2 (#7807d2)
U 3 (#a77fa3)
L 2 (#015232)
U 2 (#7a21e3)`;

describe('day18', () => {
it('part 1', () => {
expect(part1(input)).toEqual(62);
expect(part1(data18)).toEqual(53300);
});
it('part 2', () => {
expect(part2(input)).toEqual(952408144115);
expect(part2(data18)).toEqual(64294334780659);
});
});
Loading

0 comments on commit 47c7b9a

Please sign in to comment.