-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
69ccba0
commit 47c7b9a
Showing
39 changed files
with
8,135 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
Oops, something went wrong.