day25 finished

This commit is contained in:
Ruediger Ludwig 2022-12-28 15:39:38 +01:00
parent c2ebf9dc84
commit 56764331a4
6 changed files with 247 additions and 25 deletions

View file

@ -8,11 +8,13 @@ I use python 3.11 without any libraries beyond the standard.
| Day | Time | Rank | Score | Time | Rank | Score |
| --- | --------- | ----- | ----- | -------- | ----- | ----- |
| 24 | >24h |11497 | 0 | >24h | 11666 | 0 |
| 23 | >24h |13621 | 0 | >24h | 13384 | 0 |
| 25 | >24h | 14695 | 0 | >24h | 9050 | 0 |
| 24 | >24h | 11497 | 0 | >24h | 11666 | 0 |
| 23 | >24h | 13621 | 0 | >24h | 13384 | 0 |
| 22 | 01:30:48 | 2540 | 0 | >24h | 10636 | 0 |
| 21 | 00:20:57 | 2178 | 0 | 01:10:59 | 2175 | 0 |
| 20 | 11:19:34 | 9421 | 0 | 11:24:45 | 8501 | 0 |
| 19 | >24h | 14445 | 0 | >24h | 13544 | 0 |
| 18 | 00:31:49 | 3269 | 0 | 01:51:15 | 3121 | 0 |
| 17 | 01:21:11 | 2058 | 0 | 02:42:45 | 1665 | 0 |
| 16 | 02:44:20 | 2611 | 0 | >24h | 10509 | 0 |
@ -26,9 +28,9 @@ I use python 3.11 without any libraries beyond the standard.
| 8 | 00:41:51 | 7831 | 0 | 00:59:27 | 6325 | 0 |
| 7 | 00:34:59 | 2683 | 0 | 00:45:45 | 2943 | 0 |
| 6 | 00:14:52 | 9153 | 0 | 00:17:06 | 8413 | 0 |
| 5 | 01:01:27 |11570 | 0 | 01:05:20 | 10701 | 0 |
| 5 | 01:01:27 | 11570 | 0 | 01:05:20 | 10701 | 0 |
| 4 | 00:12:09 | 5789 | 0 | 00:16:03 | 5187 | 0 |
| 3 | 00:47:15 |13278 | 0 | 01:07:44 | 12947 | 0 |
| 3 | 00:47:15 | 13278 | 0 | 01:07:44 | 12947 | 0 |
| 2 | 00:21:47 | 8874 | 0 | 00:36:49 | 9949 | 0 |
| 1 | 00:10:25 | 5460 | 0 | 00:14:20 | 5269 | 0 |

View file

View file

@ -0,0 +1,13 @@
1=-0-2
12111
2=0=
21
2=01
111
20012
112
1=-1=
1-12
12
1=
122

View file

@ -0,0 +1,143 @@
1=0=01=0=2111-1211
1==21=
20--
1-=1200=-=0
211==12=2=0111==
2=-10
1221=221=0-1=-
12=02=-12020=12=01-
12112101
20
120120=21=1002-1
10==1-02=1
1=11200001-=--
1=222-1=012=2
20===1-1102-=
1020
102=-==-=2-
112-2112-00012-
1010=--121
202022=-=2-22=
122==1=1020011=-00
10212==-0
2=--12020=1-0=-2=-
1110-1-2
20==210221=-21--12
1=-02--=22=-122
2=-=0=00=1--1-2=--
2==2==2-
2=12=1
2=01=
202=20202-000
1=0-=020021022012
2=0-011-=2=-0-=21
1=211
1-=1=11=--010=---
1000020-12==
2-=122-1211-0=
10=2220122012
2=21-01=212
10111==2=2-12
111
1=2---2211=2011=--
1--=0000=1-020
2=02-=-
1-011=
12020-0=-1-220100
2-==000=21=1
2-0100000-12-2-=
1-=1
1221=2-1==02-=202
200
122-2-0
10=2101-22
1==-120-1
2=2=2=-11--==-==
2111-=2=-=-2
1--
1-0=10-0112-12=
10=
2=01=1=-=20=
1=
1211-2=-1=
222=
122=2-1-0
1-2=20-=02122-1
1==-=2===0-=1100--11
12-0=201=10=-=
1=01=2=22-2-1-1
120==222100=0
11=-=--12=2-1101
102=1221=---0==021
2-=-2=202-=-==
100=1=02020-221=
1=0=-220=
1001-
20==2==1-1
1=2-2=2=-12=
10=0--2
10-202-2002=22=
2=2=
1-011=0=-12---
1002220
2=
1--=2---111
222==2
11100
1=0=201
1--02-
1=11-==0=021
1-=00=
1==12-20-=002001=
1=0=-=21-
1000-1=0-0=1=01-2-
2==
1-0
1=101-0-1
1=0=
11=2==-0-2202-0=
10-0=0=1-002
1-=0210=01120-
1112=2-0-2=-01
1-1=022=21
2=1-2--120
10002--0=220-0-2=12
11002102100
11000-2-12
120=-==1-2-=
21
11
2=121-
1==
1=-
1-=--2=-
2=-10-=0
2200-1-
2=21-1200==
1-102210=002=--112
1-10
122=202=201-=-10-1
2212121=02102
21=2-211=-1-20-
101-=01-1
200012112=
22=21201=22
1-1212=1-=1
1212-==1=01
22==--=
1=-2-1-==020-10-=
1=1210=--00
1=--=1=
2010111-00111-2=2
11=21-0=2-01
21=
1=-0-220
102-=0
1=---0-
1-1122-=121222--0
10110=1-20--1-1
20=--21220-=
1=---22-
2-000===1101=
20-
10==

View file

@ -0,0 +1,33 @@
from __future__ import annotations
from typing import Iterator
day_num = 25
def part1(lines: Iterator[str]) -> str:
snafu = sum(from_snafu(line) for line in lines)
return to_snafu(snafu)
def part2(lines: Iterator[str]) -> None:
return None
SNAFU = "=-012"
def from_snafu(line: str) -> int:
result = 0
for char in line:
result = result * 5 + SNAFU.index(char) - 2
return result
def to_snafu(number: int) -> str:
result = ""
while number > 0:
mod = (number + 2) % 5
result = SNAFU[mod] + result
number = (number - mod + 2) // 5
return result

View file

@ -0,0 +1,31 @@
from advent.common import input
from .solution import day_num, part1, part2, from_snafu, to_snafu
def test_part1():
lines = input.read_lines(day_num, 'example01.txt')
expected = "2=-1=0"
result = part1(lines)
assert result == expected
def test_part2():
lines = input.read_lines(day_num, 'example01.txt')
expected = None
result = part2(lines)
assert result == expected
def test_976():
input = "2=-01"
expected = 976
result = from_snafu(input)
assert result == expected
def test_4890():
input = 4890
expected = "2=-1=0"
result = to_snafu(input)
assert result == expected