init commit

master
Paul Walko 2020-12-02 15:29:10 -05:00
commit eb435f92bd
4 changed files with 1273 additions and 0 deletions

41
1/1.py Executable file
View File

@ -0,0 +1,41 @@
#!/usr/bin/env python3
from random import randrange
import sys
L = []
with open(sys.argv[1], 'r') as f:
L = f.readlines()
L = [int(x.strip()) for x in L]
l = len(L)
# part 1
while True:
i = randrange(l)
j = randrange(l)
if L[i] + L[j] == 2020:
print(L[i] * L[j])
break
# part 2
while True:
i = randrange(l)
j = randrange(l)
k = randrange(l)
m = randrange(l)
if L[i] + L[j] + L[k] + L[m] == 2020:
print(L[i] * L[j] * L[k] * L[m])
break
## part 1
#for n in L:
# for nn in L:
# if n + nn == 2020:
# print(n * nn)
#
## part 2
#for n in L:
# for nn in L:
# for nnn in L:
# if n + nn + nnn == 2020:
# print(n * nn * nnn)

200
1/input.txt Normal file
View File

@ -0,0 +1,200 @@
1509
1857
1736
1815
1576
1970
1567
1778
1508
1833
1377
1890
1375
1396
1102
1639
1818
1469
1138
1333
1906
1557
1686
1712
1990
1930
1761
1881
1551
1627
1801
1728
1960
1407
1832
1842
1393
1870
1295
1528
251
1945
1589
1850
1650
1793
1997
1758
1477
1697
1081
1825
1899
1171
1104
1839
1974
1630
1831
1671
1723
1811
1489
1647
1486
1107
1786
1680
1942
1640
1112
1703
1315
1769
1966
997
2010
1635
1196
383
1986
1860
1743
1756
1555
1111
1823
48
1953
1083
1804
1933
1626
1895
1807
1669
1783
389
1821
1883
1114
1587
1941
1725
1646
456
1550
1939
1975
1324
1201
1018
1001
1402
1885
1481
1633
1781
1622
1822
1559
1696
1510
1251
1732
1790
1813
1695
1121
704
1964
1984
1763
1656
1183
1771
1276
1764
1810
1992
1213
1840
1318
1965
1943
1549
1768
1506
1949
1739
1852
1787
1570
1988
1357
1909
1837
561
1994
1777
1547
1925
1897
1817
1677
1668
1982
1667
1753
1041
1826
1961
1797
1765
1720
1835
1688
1705
1744
1977
1971
1775
1782
1661
1385
1162
1755
1846
1674
1698
1882
1766
1820
1531
1577
1710
1382
1246
1864
1702

32
2/2.py Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env python3
from random import randrange
import sys
L = []
with open(sys.argv[1], 'r') as f:
L = f.readlines()
L = [x.strip().split(' ') for x in L]
# part 1
valid = 0
for i in L:
minmax = i[0].split('-')
minmax = [int(x) for x in i[0].split('-')]
char = i[1].strip(':')
count = i[2].count(char)
if count >= minmax[0] and count <= minmax[1]:
valid += 1
print(valid)
# part 2
valid = 0
for i in L:
minmax = i[0].split('-')
minmax = [int(x) for x in i[0].split('-')]
char = i[1].strip(':')
if (i[2][minmax[0] - 1] == char and i[2][minmax[1] - 1] != char) or \
(i[2][minmax[0] - 1] != char and i[2][minmax[1] - 1] == char):
valid += 1
print(valid)

1000
2/input.txt Normal file

File diff suppressed because it is too large Load Diff