first commit
This commit is contained in:
14
2020/01/01.py
Executable file
14
2020/01/01.py
Executable file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Advent Of Code 2020 - Day 1
|
||||
|
||||
filename = "input.txt"
|
||||
|
||||
with open(filename) as f:
|
||||
content = f.readlines()
|
||||
content = [x.strip() for x in content]
|
||||
|
||||
for i in content:
|
||||
for j in content:
|
||||
if ( int(i)+int(j) == 2020 ):
|
||||
print (int(i)*int(j))
|
15
2020/01/01b.py
Executable file
15
2020/01/01b.py
Executable file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Advent Of Code 2020 - Day 1 - Part 2
|
||||
|
||||
filename = "input.txt"
|
||||
|
||||
with open(filename) as f:
|
||||
content = f.readlines()
|
||||
content = [x.strip() for x in content]
|
||||
|
||||
for i in content:
|
||||
for j in content:
|
||||
for k in content:
|
||||
if ( int(i)+int(j)+int(k) == 2020 ):
|
||||
print (int(i)*int(j)*int(k))
|
200
2020/01/input.txt
Normal file
200
2020/01/input.txt
Normal file
@ -0,0 +1,200 @@
|
||||
1228
|
||||
1584
|
||||
1258
|
||||
1692
|
||||
1509
|
||||
1927
|
||||
1177
|
||||
1854
|
||||
1946
|
||||
1815
|
||||
1925
|
||||
1531
|
||||
1529
|
||||
1920
|
||||
1576
|
||||
1392
|
||||
1744
|
||||
1937
|
||||
1636
|
||||
1615
|
||||
1944
|
||||
1949
|
||||
1931
|
||||
1253
|
||||
1587
|
||||
1860
|
||||
1874
|
||||
1611
|
||||
2008
|
||||
1182
|
||||
1900
|
||||
1515
|
||||
1978
|
||||
1996
|
||||
116
|
||||
1588
|
||||
1322
|
||||
1680
|
||||
1174
|
||||
1712
|
||||
1513
|
||||
1778
|
||||
1443
|
||||
1569
|
||||
1453
|
||||
708
|
||||
1783
|
||||
1926
|
||||
1959
|
||||
2001
|
||||
1776
|
||||
1643
|
||||
1654
|
||||
1934
|
||||
1983
|
||||
1630
|
||||
1382
|
||||
1486
|
||||
1422
|
||||
1836
|
||||
1728
|
||||
1315
|
||||
1843
|
||||
1521
|
||||
1995
|
||||
1403
|
||||
1897
|
||||
1280
|
||||
1981
|
||||
1901
|
||||
1870
|
||||
1519
|
||||
1945
|
||||
1857
|
||||
591
|
||||
1329
|
||||
1954
|
||||
1679
|
||||
1726
|
||||
1846
|
||||
1709
|
||||
1695
|
||||
1293
|
||||
1602
|
||||
1665
|
||||
1940
|
||||
1921
|
||||
1861
|
||||
1710
|
||||
1524
|
||||
1303
|
||||
1849
|
||||
1742
|
||||
1892
|
||||
1913
|
||||
1530
|
||||
1484
|
||||
1903
|
||||
1545
|
||||
1609
|
||||
1652
|
||||
1908
|
||||
1923
|
||||
1188
|
||||
1649
|
||||
1994
|
||||
1790
|
||||
1832
|
||||
140
|
||||
867
|
||||
1664
|
||||
1598
|
||||
1371
|
||||
1018
|
||||
35
|
||||
1833
|
||||
1161
|
||||
1898
|
||||
1482
|
||||
1767
|
||||
1252
|
||||
1882
|
||||
1448
|
||||
1032
|
||||
1459
|
||||
1661
|
||||
1391
|
||||
1770
|
||||
1806
|
||||
1465
|
||||
1295
|
||||
1546
|
||||
1355
|
||||
1358
|
||||
1321
|
||||
1368
|
||||
1514
|
||||
1756
|
||||
1775
|
||||
1957
|
||||
1468
|
||||
1975
|
||||
631
|
||||
1812
|
||||
1151
|
||||
1167
|
||||
1251
|
||||
1960
|
||||
1991
|
||||
1972
|
||||
1936
|
||||
1552
|
||||
1419
|
||||
1577
|
||||
1549
|
||||
1580
|
||||
1974
|
||||
1830
|
||||
1813
|
||||
1893
|
||||
1492
|
||||
1389
|
||||
1454
|
||||
1522
|
||||
1556
|
||||
1172
|
||||
1653
|
||||
1822
|
||||
1328
|
||||
1907
|
||||
1999
|
||||
1281
|
||||
1912
|
||||
1919
|
||||
1896
|
||||
1722
|
||||
1341
|
||||
1720
|
||||
1201
|
||||
1512
|
||||
1298
|
||||
1254
|
||||
1947
|
||||
1505
|
||||
1594
|
||||
1334
|
||||
1592
|
||||
1943
|
||||
1405
|
||||
1589
|
||||
1263
|
||||
1930
|
||||
1736
|
||||
1180
|
||||
1984
|
||||
1401
|
||||
1340
|
||||
1292
|
||||
1979
|
||||
1876
|
36
2020/02/02.py
Executable file
36
2020/02/02.py
Executable file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Advent Of Code 2020 - Day 2
|
||||
|
||||
"""
|
||||
1-5 k: kkkkhkkkkkkkkkk
|
||||
5-7 k: blkqhtxfgktdkxzkksk
|
||||
"""
|
||||
|
||||
filename = "input.txt"
|
||||
|
||||
with open(filename) as f:
|
||||
content = f.readlines()
|
||||
#content = [x.strip() for x in content]
|
||||
|
||||
validPasswords = 0
|
||||
|
||||
for i in content:
|
||||
line = i.split()
|
||||
|
||||
xMin = int(line[0].split("-")[0])
|
||||
xMax = int(line[0].split("-")[1])
|
||||
|
||||
character = line[1].rstrip(":")
|
||||
|
||||
password = line[2]
|
||||
|
||||
count = 0
|
||||
for c in password:
|
||||
if c == character:
|
||||
count = count + 1
|
||||
|
||||
if (count >= xMin) and (count <= xMax):
|
||||
validPasswords = validPasswords + 1
|
||||
|
||||
print (validPasswords)
|
39
2020/02/02b.py
Executable file
39
2020/02/02b.py
Executable file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Advent Of Code 2020 - Day 2
|
||||
|
||||
"""
|
||||
1-5 k: kkkkhkkkkkkkkkk
|
||||
5-7 k: blkqhtxfgktdkxzkksk
|
||||
"""
|
||||
|
||||
filename = "input.txt"
|
||||
|
||||
def logical_xor(str1, str2):
|
||||
return bool(str1) ^ bool(str2)
|
||||
|
||||
with open(filename) as f:
|
||||
content = f.readlines()
|
||||
#content = [x.strip() for x in content]
|
||||
|
||||
validPasswords = 0
|
||||
|
||||
for i in content:
|
||||
line = i.split()
|
||||
|
||||
pos1 = int(line[0].split("-")[0])-1
|
||||
pos2 = int(line[0].split("-")[1])-1
|
||||
|
||||
character = line[1].rstrip(":")
|
||||
|
||||
password = line[2]
|
||||
p1 = password[pos1]
|
||||
p2 = password[pos2]
|
||||
|
||||
# (a and not b) or (not a and b)
|
||||
|
||||
if ( (p1 == character) and (p2 != character) ) or ( (p1 != character) and (p2 == character) ):
|
||||
validPasswords = validPasswords + 1
|
||||
|
||||
|
||||
print (validPasswords)
|
1000
2020/02/input.txt
Normal file
1000
2020/02/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
3
2020/02/inputShort.txt
Normal file
3
2020/02/inputShort.txt
Normal file
@ -0,0 +1,3 @@
|
||||
1-3 a: abcde
|
||||
1-3 b: cdefg
|
||||
2-9 c: ccccccccc
|
Reference in New Issue
Block a user