Taddeus Kroes 2 rokov pred
rodič
commit
8872d7748d
2 zmenil súbory, kde vykonal 150 pridanie a 0 odobranie
  1. 16 0
      2022/25_snafu.py
  2. 134 0
      2022/input/25

+ 16 - 0
2022/25_snafu.py

@@ -0,0 +1,16 @@
+#!/usr/bin/env python3
+import sys
+
+def to_decimal(snafu):
+    return sum(5 ** i * ('=-012'.index(digit) - 2)
+               for i, digit in enumerate(reversed(snafu)))
+
+def to_snafu(decimal):
+    digits = []
+    while decimal:
+        decimal, rem = divmod(decimal, 5)
+        decimal += rem > 2
+        digits.append('012=-'[rem])
+    return ''.join(reversed(digits))
+
+print(to_snafu(sum(to_decimal(line.rstrip()) for line in sys.stdin)))

+ 134 - 0
2022/input/25

@@ -0,0 +1,134 @@
+1====-
+210112-
+2==
+1-==-0=0=
+2-112==2=-01120=-
+1200=--2=1022-=1=1
+2=0---22
+1-2-10-1=
+10010=12
+10==
+1--002
+1=20-0--==0102===
+201202---0110--1-
+10111-0-122=-=
+1==-011
+1-2=12122111
+1222=1111-0==210
+2-=-22012
+1=0=
+1-2-
+22-=1===-2=0-=1
+1-=2==22022211-
+10201-201
+121--2-201-01=20-
+110=2
+22101-10-20
+1=1--=-=1-2-
+1=-2-=222220101
+11=-1=--102220
+1-11=102=20
+2012=1122=--11
+2001==0-
+2--100
+1=2=11
+1==2121-0=02
+1=201
+1---011--201-0=1
+11-20=--
+2=1-2012121-=0
+1=11-=001---1-=-1
+1021--
+1==20
+11==1=-2=210
+12-00
+10=001-121001
+1-=11210221=02
+20-20
+2=1-2=2
+1=020121==
+120212=2=00
+2=-0-21200==212
+102
+100
+1-21==0002202-21=-1
+1--2001=20211=202
+1122
+1=021
+102-01002
+110121111-=0=
+111=0101-01=
+20=2
+2200-=-0212-112
+1-0====
+10=02==00--21=2
+121=112122==2=2211
+220==102--=0
+10111220==10=2
+1-=102=
+1001-2=
+2-2===10
+1=1
+1--1--1221012210-0
+1==---101
+1102020121-12
+1-=
+122--011
+1=20022
+2-11
+11-1=0-=21-=
+2
+1=10
+22--2--20=
+222
+21=-022==-
+1-02===12=-22=012
+1=0===01=---
+12=
+10--0-
+2-=2=0-
+11002220--0=2==0
+220-0-2-020-1==211-
+1-12=1
+121-=-0==-=00120-=2
+1011020
+210=-01-
+21=121-2-2--=112=
+1-20-2=-00=110
+201=1102-=2-112=12
+20222002-01002=
+21-
+12=11-=-==2-21=1-
+1-
+1=2--000-
+1-=0=2=2=
+12--=-2-0121-00-12
+2=1=22=
+1-220-20
+111==01=12
+21----12=
+1==1-0===200
+1=-21-2-0=0-1012-2
+10=0-0=--011=
+2=10=21=21=2012-1
+121010
+2==1-121-2
+121-
+101002-0-2=-0=2112
+1012=-=01-22=2=0=
+11=2
+1=1==-
+2-0--=0---2-11=
+2-=0=02=0-12--1=
+12-0--
+1==102
+2220=--
+1=022=1=110-22==-
+110===0-22-2=101=
+11=----10-11
+1-=12
+2-=00=22==
+1=0=--=2
+22
+1-=20
+121-11-1-