Compare commits

...

6 commits

21 changed files with 5825 additions and 25 deletions

View file

@ -12,3 +12,5 @@ https://adventofcode.com/2020/
| 4 | `**` | `**` | | | 4 | `**` | `**` | |
| 5 | | `**` | | | 5 | | `**` | |
| 6 | | `**` | | | 6 | | `**` | |
`test.sh` can be used to run all solutions and automatically compares them to (my) puzzle inputs and the expected outputs.

2
data/day1.expected Normal file
View file

@ -0,0 +1,2 @@
1018336
288756720

200
data/day1.input Normal file
View file

@ -0,0 +1,200 @@
1028
1987
1938
1136
1503
1456
1107
1535
1946
1986
855
1587
1632
1548
1384
1894
1092
1876
1914
1974
1662
1608
2004
1464
1557
1485
1267
1582
1307
1903
1102
1578
1421
1184
1290
1786
1295
1930
1131
1802
1685
1735
1498
1052
1688
990
1805
1768
1922
1781
1897
1545
1591
1393
1186
149
1619
1813
1708
1119
1214
1705
1942
1684
1460
1123
1439
1672
1980
1337
1731
1203
1481
2009
1110
1116
1443
1957
1891
1595
1951
1883
1733
1697
1321
1689
1103
1300
1262
1190
1667
1843
1544
1877
1718
1866
1929
1169
1693
1518
1375
1477
1222
1791
1612
1373
1253
1087
1959
1970
1112
1778
1412
1127
1767
1091
1653
1609
1810
1912
1917
935
1499
1878
1452
1935
1937
968
1905
1077
1701
1789
1506
1451
1125
1686
1117
1991
1215
1776
1976
846
1923
1945
1888
1193
1146
1583
1315
1372
1963
1491
1777
1799
1363
1579
1367
1863
1983
1679
1944
1654
1953
1297
530
1502
1738
1934
1185
1998
1764
1856
1207
1181
1494
1676
1900
1057
339
1994
2006
1536
2007
644
1173
1692
1493
1756
1916
1890
1908
1887
1241
1447
1997
1967
1098
1287
1392
1932

2
data/day2.expected Normal file
View file

@ -0,0 +1,2 @@
603
404

1000
data/day2.input Normal file

File diff suppressed because it is too large Load diff

2
data/day3.expected Normal file
View file

@ -0,0 +1,2 @@
205
3952146825

323
data/day3.input Normal file
View file

@ -0,0 +1,323 @@
..#...##...###.........#..#..#.
#.###........#..##.#......#...#
#.#.###..#.#..#.#............#.
.##............#......#...#.#..
..#..#.....##..##..##..........
...#...........###.#.##........
....#.#...#..#..##............#
....#....##...##..##........#..
.#..#..#....#...#..##.....##...
.#.###..#......####........##..
..#...###....#......#.....##.##
..#...#.......#......#..##....#
#...##....#.#..#.......#....#..
.#......#..#...........#....##.
.##.#......#.#.#.....##........
.....#.................#.#..#.#
....#..#........##......#..#.#.
..#...#..##.......#..##...#..#.
..#.......#.............#.#....
.#.................#.........#.
..#..#.#.#.#............##.#..#
.#.#.##.#.....#.....#..#......#
..#.#..#.#..........##........#
.........#...#.....#.#...#####.
##..#.....##.##........#...##..
.#.....#....##.#..#....##...##.
.##.....#.#....#.#.....#......#
.....#..#.##.....#.#....#.#..##
#......##..##....##...###..#...
.......#..#...........#......#.
#...#......#........#..#.......
##..#.....##.....#...#...#....#
.###..##..#.#........#..#.#....
#.#...#...#......##........#.#.
......#....#.#........##...#..#
.#.....#..#.#.....#......##....
.....#.....#.#.#....###.....#..
#.......##.#......#.#.#....###.
.......#..#..#...#.#.##........
.#......##..#.........###..#...
....#..##.......##.###...###...
.##............#..#.##.....#.##
..##.#.......##....#.......##.#
#..###............#.#...#...#.#
...##.#.#.#..#.##........#.#...
.#.....#...##.#..###..##.##...#
..............#.#.#.........#..
.....#...........#.#...#....#..
.....#...##.##.#....#.###..#...
#..###.........#......#.#.#....
.....#..#...##...###.#....#....
#..........#.#.#....#..#......#
###...................#......#.
........####......#.#..........
.......#.....#...#.......#...#.
.....#.....................#...
...#.#...#...#...........#.....
..#.........#...#....###..#....
.....#.#..##......##........##.
..#.............#............#.
.#....##.......#..#............
.#............#.#..#.##....#...
.####...##.#....#.....#...#....
##..#....#.#.#...........#..#.#
...#..#...........#...#..#....#
.....##.....#..#...#.........#.
...##........#....##........#..
.##.#...#...#..#.....#....##.#.
#.#...#.#.#.#.#..#....#....#...
#..#.#...#..#........#....#.#..
....#.#.....#......##...#....#.
.###.##...#....##.#...###..#..#
###..#...##..#......#.........#
..#.#......##.......#.....#...#
..#...#........#.........#.#...
#....#..#.........###.#......##
...#..#....#...#.......##.#.#..
....#.......#....###...##.#....
..#.....#.#.....###..#####....#
##......#....#.....##..#..#...#
#...........#..#..#....#....#..
.#...#.##.#.#.#....#......#..#.
.......#.#....#....#...#.#..#..
..#.#..#.##..##...##..#..#.....
...##.##.................#.#...
.....#...#......##.#....#.....#
......#..##.#..#.#.........#...
.............##.#......#.......
..#.#.....#...#.#.....#..#.....
.........#..#.#......#..#......
#..#.#.##..........#.##......##
......#.......#.....#..#.#...#.
.#....#....#.#.....#.......#...
#..#..##..................#....
............#...........##.#...
####...#..##.#....#.##..#......
#...#...#.....#.#...#.#........
.......##.........#.....#.....#
.....#...........##......#.####
.##....#.#.##......###.#.##....
........#.####.......#.#...#...
.#.#...##.#.#.#.........##.....
....#............###.##....#...
...##........##.#...#....#..###
..#.#.........#....##.#........
..#..##..#...##..#.##...#.....#
.#......#..#..#.........#......
..#........##.#......#.....#...
.##.......#....#.#......#......
#........#....#.####...#.#.....
##......#.............#....###.
..#....####.#.#.#.#...##......#
#.#.#.....#...#.......#...##...
........#...#....#..#......#.#.
#..#...#.#.##.....#.#....#....#
#...#....#......#.........##.##
..##.#..##............#........
#.........####.........#.......
#.##.........#..##....#.#.#.#..
.###......##..#.#.....#.#...##.
...#.........#.#...##.##....#..
#..#......#....##..#.#...#...##
...#.......#.#.#.....#..##...#.
....................###........
#...........###......#.#...##.#
.................#.#...###....#
...#..###..#.##...#..#....##...
###..#..#.#...#.....#.#.......#
.........#..#.#.....#.........#
.##..#.........#.#.....##......
.....#..........#.#.##....#....
........#.##.....#...##...#....
#.#.#...#......##....#.###.....
.#.##.....##.....#....#.##.#.##
.#...#.....##.#.##....#.....#.#
...#.....#........#............
##...####..#....#..##...#......
#.......#...#.#...#........#..#
......#.....#....#..#..#.#.....
..............##.....#.##....##
.#..##.........###..#..........
......#......#............#..#.
#.....###...###..........#.....
...###...........#....##..#....
.....................#...#.##..
###....#.#....#...#....#.#..##.
..#.............#.#....#..#.#..
.......#..###....#...#...#...#.
.##..#....##..............##...
...#...#..#..#.##.#....##...#..
#..#....##......#....###..####.
.##...#.#....#..#..#....#....#.
.#.##..#..#.........#.#......##
#..#.................#.....#...
..#............#........#...#..
##.##.......#.#....#..#....##.#
..##...#.#.....#......#........
......#.##.........##...#......
......##.#......#.##....##.#..#
.#.#......####.#.#.#.#..#......
..#.#....#...###....#.#...###..
.#.#...#....##..###.#..#.......
..#.....##..#............#..#.#
.#...#....#.....#....#..#.#.#..
..#....#..#......##...##......#
....#.......#.##.#.........#..#
#............#...##.....#..##..
......#..#..........#.#..#.....
...........#.#..#...##.#...#..#
.........###..#......##.###.#..
.....#....#......#...#....##...
..#.......#..#.#.#......#......
.#....#.....#.#.#.##...#....##.
....#.##.##.......#..#.....#...
.#.....#......#.......#..#.....
....###.....##.....##..#.#...#.
#.......#.#....#.#.#....#......
#...#..#.#......#...##.#.......
....##.##....#..#.......#..#.#.
.#.##.#.#..#.....#.#.......##..
..#..#..#..#.###...............
#.#......##....##.#.#.....#.#..
..##...#.........#.#..#.##..#..
.........####...#.....##.#.....
..#...................#.###....
..#.....#..#....#..#...........
.....###.#.........#.#.........
#..#..#........#..#......#..#..
###..##...#.......#........#.#.
.#.#.#.###.#............##.....
#..............#......#....#.##
.#...#..###...###.#..#.#.......
.###....##.#.......#.#.....###.
.##.....#.#....................
#..#.....#.....#...#.....#..##.
#.#....##..#......##..#...##..#
...........#....#..#.##.##....#
......#.......##....#.#....#.#.
###..#.#..........#.......#.#..
..#.#..##....##............##..
..#.....#..#....###............
.#...#...##...#..#..#..#.#....#
...#....#........#.............
#.#......#.#.....##..........#.
....#..#...............#...##..
........#..#....#..#..#..##....
....#......#.#.#...#.......#.##
.#.....#.#.#........###....#...
.#..#.......#...........#...#..
#.#.#####..#......#...#.#.###..
...##...#.#.....#..#...#...#...
..#....#.....#..#....#.#.....#.
....#.......#.....#........###.
..##..........#...###.......#..
#.#.##..#........##...#.#......
....##...#......#..........#.#.
#.......#..#.##.............#..
......#..........#...#....#...#
#.#.....#.##.#.#.............##
#...#.........##.##......#.##..
.........##.....#....#...##..#.
#.#...##.#...#.....##...#..#..#
......##.#.....#.#.....#.##....
....#.............#...#.......#
.#......##...#.#...#.##........
...#..#..#...........#..#..#.#.
.#...#...........#.#.##....#...
..#...#...#.#..#....#..#..#....
..###..##..#..#.........#.#..#.
....#.##.#...#.......#...#.....
.#.#.................#.......#.
.#..#.....#.##...#.#.....#...#.
.#.......#...#....#.......#....
###....##....#..#...#.#..##....
.........#.#.#.#...###.......##
....##.......#......#......##..
......##.###.#..#...#.#.#.#....
.#.###.#.#......#.#.......##...
.#.....##..#.#.....#...#.##....
.#..##.#.....#........###...#.#
.......#.#...........#........#
..........#...##..##.......#.#.
...#..#..#...#....#.#......#.#.
....#...#..#....#....#.#.##....
...#.#...##...#...##..#........
..#........#...##.#...##.#.#.#.
...##.#..#.......###.#.#.#.....
..##......#.#.#.........###.#..
.......#.#...##...#.#.......#.#
.#....##..#..#....#..#...#.....
.#....#.#.......#..#..##.#....#
#.#..##..#.#............#....#.
##..#....#.##.#....#...#..##...
.###.#.#..#...##........###.##.
...........#..#...#..#.#..###..
.#.#.#...#....#...##.##........
.....###.........#......#####..
#.#.#.....#....#..#...#.#.#.#..
..##.....#..#..#.#.#...#....#.#
......#.##..##..#.#.#.......#..
...#.#..###.........#........#.
......#.##..####...#...#..#...#
#.......#.........#....#....###
#......#...#........#.##....###
.#.#..............#...#...###.#
.#....####...#..##.###.....#...
.......#......#..#...#..##.#...
...........#.......#...........
..............#...#.#.#.#...##.
.###.....##.#.....#..........#.
##.##......#....##..#.....###.#
#.......#...##...#....##...#...
##.#.##...#....#....#....#.....
.....####...........#.#......#.
......#...#....#..#......#.....
...#...##..........#.......##.#
.#....#..........#.####........
...##...#..#...##........##..#.
.........##....#...##..#.##.#..
##.#.....#.......#.....#.......
#..#....#.##.#........#........
#.#...#...##........#.#.....###
....#...................#.#.#..
.......#..#.#...#....#.##.#....
....##...###.#.#.##...#...#....
.#....#....#...##.#......#...#.
............##..#.#.#........#.
...#....#.....#......#........#
...#.#.....#.##.....#....#...#.
.....#..##.......#.##.......#.#
........##................#....
....#..###...##.#..#...#......#
.#.#.......#.......#....##.#..#
..#........#............#......
..##.......#..#..#....#....#..#
#...###.......#.##...#.........
.....#...#...#..##..#....#..#..
.##.#..#...##.........###.#....
..#.#..#...#...####.#...#.#.#.#
#....#..###.....#......#.##..##
##......#...##...###......#.##.
...........#.....##...#...#...#
..#..#.#.....#..#.....###...#..
.............#..........###...#
....##............#....###.##.#
..##.#..##.....#.#.........#.#.
....#.#...........####.........
.##.###.##.#.#......#.##.#.#...
.....##.........#..#.......#...
...........#.........#....###..
...#.#..#..........#.....#..#..
.#..###.......##........#.#....
.#...###.....#..#.#..#...#.##..
##...###.#.#....#......#...#..#
....#.......#..#..##..#.#......
#.#......#.##..#......#..#....#
....#..#..#.....#.#......#..#..
..#...###......##.............#
..#....####...##.#...##.#......
.....#.......###...............
.......#...#.#.......#.#.##.###
.#.#...#.....#...##.........#..
..#..........#..#.........##...

2
data/day4.expected Normal file
View file

@ -0,0 +1,2 @@
202
137

1068
data/day4.input Normal file

File diff suppressed because it is too large Load diff

2
data/day5.expected Normal file
View file

@ -0,0 +1,2 @@
998
676

960
data/day5.input Normal file
View file

@ -0,0 +1,960 @@
BFBBBBBLLR
BBFFBBFRRL
FBFBFFFRRL
BBFFFBFRRL
BFFBFBFRLL
FFBBBFBLRL
BFFFBFFLLR
FBFFFFBLRR
FBFFBBBRRR
BFFBFFFLLR
BFFFFFBLLL
FFBBFFBLRR
BFFFFFBRLR
FBFBFBFLLL
FFBFBFFLLL
BBFFFFFLLL
FFFBBBFLLL
BBFFBFBLLR
FFBFBFBRRR
BFFBFFFRRR
BBFFBFBRLR
FFFBFBFLRL
BBFFBBBLRR
FBBFFFFLLR
BBBFBBFLLL
BFFFFBBRLL
FBBFBFBRRL
FFBBBFFRRR
BBFFFFBRRR
FBBBBFFLLR
BFFFFFBLRR
FF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 +1,2 @@
6683
3122

2179
data/day6.input Normal file

File diff suppressed because it is too large Load diff

View file

@ -16,7 +16,6 @@ def find_summing(arity: int, nums: Iterable[int]) -> int:
return product(next(filter(lambda xs: sum(xs) == 2020, itertools.permutations(nums, r=arity)))) return product(next(filter(lambda xs: sum(xs) == 2020, itertools.permutations(nums, r=arity))))
if __name__ == '__main__': if __name__ == '__main__':
with open(sys.argv[1], 'r') as f: nums = [int(n) for n in sys.stdin.readlines()]
nums = [int(n) for n in f.readlines()]
print(find_summing(2, nums)) print(find_summing(2, nums))
print(find_summing(3, nums)) print(find_summing(3, nums))

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
import re import re
import sys
from collections import Counter from collections import Counter
r = re.compile(r'(\d+)-(\d+) (.): (.*)') r = re.compile(r'(\d+)-(\d+) (.): (.*)')
@ -15,8 +16,7 @@ def do_line(req_func, line):
return req_func(int(min_required), int(max_required), letter, password) return req_func(int(min_required), int(max_required), letter, password)
if __name__ == '__main__': if __name__ == '__main__':
with open('input.txt', 'r') as f: lines = list(sys.stdin.readlines())
lines = list(f.readlines())
for func in (requirements_met_1, requirements_met_2): for func in (requirements_met_1, requirements_met_2):
print(len(list(filter(lambda line: do_line(func, line), lines)))) print(len(list(filter(lambda line: do_line(func, line), lines))))

View file

@ -1,21 +1,25 @@
#!/usr/bin/env sh #!/usr/bin/bash
set -eu set -eu
INPUT=$(readlink --canonicalize-existing "$1")
MODE=${2:-}
GHDLFLAGS="--std=08 --workdir=workdir" GHDLFLAGS="--std=08 --workdir=workdir"
cd "$(dirname "${BASH_SOURCE[0]}")"
mkdir -p workdir mkdir -p workdir
ghdl remove $GHDLFLAGS if [[ $MODE = "--synth" ]]; then
ghdl analyze $GHDLFLAGS parser.vhd verifier.vhd top.vhd sim.vhd
ghdl elab-run $GHDLFLAGS sim -gSTEP=1 -gFILENAME="../input.txt"
ghdl elab-run $GHDLFLAGS sim -gSTEP=2 -gFILENAME="../input.txt"
echo "Synthesized: "
for step in 1 2; do for step in 1 2; do
ghdl remove $GHDLFLAGS ghdl remove $GHDLFLAGS
ghdl synth $GHDLFLAGS -gCOUNTER_WIDTH=12 -gSTEP="$step" parser.vhd verifier.vhd top.vhd -e top > top_syn.vhd ghdl synth $GHDLFLAGS -gCOUNTER_WIDTH=12 -gSTEP="$step" parser.vhd verifier.vhd top.vhd -e top > top_syn.vhd 2>/dev/null
ghdl analyze $GHDLFLAGS top_syn.vhd sim.vhd ghdl analyze $GHDLFLAGS top_syn.vhd sim.vhd
ghdl elab-run $GHDLFLAGS sim -gSTEP="$step" -gFILENAME="../input.txt" --ieee-asserts=disable-at-0 ghdl elab-run $GHDLFLAGS sim -gSTEP="$step" --ieee-asserts=disable < "$INPUT"
done done
else
ghdl remove $GHDLFLAGS
ghdl analyze $GHDLFLAGS parser.vhd verifier.vhd top.vhd sim.vhd
ghdl elab-run $GHDLFLAGS sim -gSTEP=1 < "$INPUT"
ghdl elab-run $GHDLFLAGS sim -gSTEP=2 < "$INPUT"
fi

View file

@ -6,14 +6,12 @@ use std.textio.all;
entity sim is entity sim is
generic ( generic (
FILENAME : string := "input.txt";
COUNTER_WIDTH : positive := 12; COUNTER_WIDTH : positive := 12;
STEP : natural range 1 to 2 STEP : natural range 1 to 2
); );
end entity; end entity;
architecture a of sim is architecture a of sim is
file file_handle : text open read_mode is FILENAME;
signal char_in : character; signal char_in : character;
signal clk, reset, is_record : std_logic; signal clk, reset, is_record : std_logic;
signal num_verified : unsigned(COUNTER_WIDTH-1 downto 0); signal num_verified : unsigned(COUNTER_WIDTH-1 downto 0);
@ -49,8 +47,8 @@ begin
cycle_clock; cycle_clock;
lines_loop: loop lines_loop: loop
exit lines_loop when endfile(file_handle); exit lines_loop when endfile(input);
readline(file_handle, current_line); readline(input, current_line);
is_record <= '1'; is_record <= '1';

View file

@ -1,5 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
import sys
def count_trees(right, down, lines): def count_trees(right, down, lines):
n = 0 n = 0
for i, line in enumerate(lines[::down]): for i, line in enumerate(lines[::down]):
@ -9,8 +11,7 @@ def count_trees(right, down, lines):
return n return n
if __name__ == '__main__': if __name__ == '__main__':
with open('input.txt', 'r') as f: lines = [line.strip() for line in sys.stdin.readlines()]
lines = [line.strip() for line in f.readlines()]
print(count_trees(3, 1, lines)) print(count_trees(3, 1, lines))

View file

@ -3,6 +3,7 @@ import AoC
import Control.Applicative ((<|>)) import Control.Applicative ((<|>))
import Control.Monad (guard, mfilter) import Control.Monad (guard, mfilter)
import Data.Char (isDigit) import Data.Char (isDigit)
import Data.List (intercalate)
import Data.Maybe (mapMaybe) import Data.Maybe (mapMaybe)
import Text.ParserCombinators.ReadP import Text.ParserCombinators.ReadP
import Text.Read (readMaybe) import Text.Read (readMaybe)

View file

@ -1,5 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
import sys
def within(a, b, x): def within(a, b, x):
return a <= x <= b return a <= x <= b
@ -48,8 +50,7 @@ def split_on(f, it):
yield current_part yield current_part
if __name__ == '__main__': if __name__ == '__main__':
with open('input.txt', 'r') as f: lines = [line.strip() for line in sys.stdin.readlines()]
lines = [line.strip() for line in f.readlines()]
specs = list(' '.join(lines) for lines in split_on(lambda l: l == "", lines)) specs = list(' '.join(lines) for lines in split_on(lambda l: l == "", lines))

52
test.sh Executable file
View file

@ -0,0 +1,52 @@
#!/usr/bin/bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
run_solution() {
if [ -d "$solution" ]; then
runfile=$solution/run.sh
[ -f "$runfile" ] || { echo "Error: $runfile not found"; exit 1; }
"$runfile" "$input"
else
case "$(basename "$solution")" in
*.hs)
runhaskell -icommon "$solution" < "$input"
;;
*.py)
python "$solution" < "$input"
;;
*)
echo "Error: Unknown solution type: $solution"
exit 1
;;
esac
fi
}
for day in day*; do
input=data/$day.input
expected=data/$day.expected
for solution in "$day"/*; do
echo -n "$solution... "
solution_output=$(mktemp)
trap "rm $solution_output" EXIT
run_solution "$solution" > "$solution_output"
if ! diff -u "$expected" "$solution_output"; then
echo FAIL
rv=$?
case "$rv" in
1)
exit 2
;;
*)
exit 1
;;
esac
else
echo ok
fi
done
done