More solutions
This commit is contained in:
200
2020/01.input
Normal file
200
2020/01.input
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
1883
|
||||||
|
1543
|
||||||
|
1801
|
||||||
|
1731
|
||||||
|
1070
|
||||||
|
1631
|
||||||
|
1490
|
||||||
|
1179
|
||||||
|
1098
|
||||||
|
1582
|
||||||
|
1717
|
||||||
|
1830
|
||||||
|
1408
|
||||||
|
1524
|
||||||
|
889
|
||||||
|
985
|
||||||
|
2005
|
||||||
|
1540
|
||||||
|
1085
|
||||||
|
1607
|
||||||
|
1518
|
||||||
|
1993
|
||||||
|
1496
|
||||||
|
1537
|
||||||
|
1514
|
||||||
|
1719
|
||||||
|
1218
|
||||||
|
1420
|
||||||
|
1027
|
||||||
|
1339
|
||||||
|
1430
|
||||||
|
989
|
||||||
|
1613
|
||||||
|
1970
|
||||||
|
1227
|
||||||
|
1082
|
||||||
|
1079
|
||||||
|
1068
|
||||||
|
1674
|
||||||
|
1186
|
||||||
|
1744
|
||||||
|
1297
|
||||||
|
1467
|
||||||
|
1647
|
||||||
|
1141
|
||||||
|
1825
|
||||||
|
1759
|
||||||
|
1395
|
||||||
|
1596
|
||||||
|
1405
|
||||||
|
1844
|
||||||
|
1461
|
||||||
|
1762
|
||||||
|
1122
|
||||||
|
1173
|
||||||
|
1838
|
||||||
|
1983
|
||||||
|
1632
|
||||||
|
1995
|
||||||
|
1245
|
||||||
|
1454
|
||||||
|
1120
|
||||||
|
1671
|
||||||
|
1526
|
||||||
|
1572
|
||||||
|
1929
|
||||||
|
1642
|
||||||
|
1864
|
||||||
|
1351
|
||||||
|
1155
|
||||||
|
1885
|
||||||
|
1226
|
||||||
|
1810
|
||||||
|
1252
|
||||||
|
1061
|
||||||
|
1882
|
||||||
|
2002
|
||||||
|
1627
|
||||||
|
1128
|
||||||
|
1575
|
||||||
|
1750
|
||||||
|
1046
|
||||||
|
1767
|
||||||
|
1270
|
||||||
|
1037
|
||||||
|
1198
|
||||||
|
1942
|
||||||
|
1074
|
||||||
|
1820
|
||||||
|
1301
|
||||||
|
1382
|
||||||
|
1687
|
||||||
|
1824
|
||||||
|
1996
|
||||||
|
1704
|
||||||
|
1051
|
||||||
|
1546
|
||||||
|
1431
|
||||||
|
1102
|
||||||
|
1041
|
||||||
|
1547
|
||||||
|
1202
|
||||||
|
1875
|
||||||
|
1800
|
||||||
|
1433
|
||||||
|
1901
|
||||||
|
1165
|
||||||
|
1151
|
||||||
|
1785
|
||||||
|
1903
|
||||||
|
1278
|
||||||
|
1185
|
||||||
|
1940
|
||||||
|
1935
|
||||||
|
1479
|
||||||
|
1495
|
||||||
|
719
|
||||||
|
1683
|
||||||
|
1972
|
||||||
|
1483
|
||||||
|
1589
|
||||||
|
1636
|
||||||
|
1055
|
||||||
|
1317
|
||||||
|
1530
|
||||||
|
1990
|
||||||
|
1099
|
||||||
|
1697
|
||||||
|
1286
|
||||||
|
1089
|
||||||
|
1136
|
||||||
|
1383
|
||||||
|
1802
|
||||||
|
1618
|
||||||
|
1050
|
||||||
|
1980
|
||||||
|
1279
|
||||||
|
1777
|
||||||
|
1635
|
||||||
|
1721
|
||||||
|
1660
|
||||||
|
1569
|
||||||
|
1554
|
||||||
|
1432
|
||||||
|
1695
|
||||||
|
1551
|
||||||
|
1601
|
||||||
|
1263
|
||||||
|
1866
|
||||||
|
1998
|
||||||
|
1466
|
||||||
|
1205
|
||||||
|
1445
|
||||||
|
1578
|
||||||
|
1267
|
||||||
|
1873
|
||||||
|
1610
|
||||||
|
1900
|
||||||
|
1192
|
||||||
|
1827
|
||||||
|
1305
|
||||||
|
1528
|
||||||
|
1140
|
||||||
|
1440
|
||||||
|
1269
|
||||||
|
1748
|
||||||
|
1187
|
||||||
|
52
|
||||||
|
1149
|
||||||
|
1603
|
||||||
|
1033
|
||||||
|
1650
|
||||||
|
1045
|
||||||
|
1345
|
||||||
|
1710
|
||||||
|
1955
|
||||||
|
1891
|
||||||
|
1392
|
||||||
|
1870
|
||||||
|
1357
|
||||||
|
1197
|
||||||
|
1087
|
||||||
|
1690
|
||||||
|
1090
|
||||||
|
622
|
||||||
|
1590
|
||||||
|
1304
|
||||||
|
1533
|
||||||
|
1971
|
||||||
|
1959
|
||||||
|
1842
|
||||||
|
1172
|
||||||
|
1653
|
||||||
|
1093
|
||||||
|
1299
|
||||||
|
1203
|
||||||
|
1119
|
||||||
|
1193
|
||||||
|
1223
|
||||||
|
1291
|
||||||
17
2020/01.py
Normal file
17
2020/01.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# with open('./2020/01.test') as input:
|
||||||
|
with open('./2020/01.input') as input:
|
||||||
|
input_list = input.read().split('\n')
|
||||||
|
for i in range(len(input_list)):
|
||||||
|
input_list[i] = int(input_list[i])
|
||||||
|
|
||||||
|
for i in range(len(input_list) - 1):
|
||||||
|
for i2 in range(i + 1, len(input_list)):
|
||||||
|
if 2020 - input_list[i] == input_list[i2]:
|
||||||
|
print(input_list[i] * input_list[i2])
|
||||||
|
|
||||||
|
for i in range(len(input_list) - 2):
|
||||||
|
for i2 in range(i + 1, len(input_list) - 1):
|
||||||
|
for i3 in range(i2 + 1, len(input_list)):
|
||||||
|
if 2020 - input_list[i] - input_list[i2] == input_list[i3]:
|
||||||
|
print(input_list[i] * input_list[i2] * input_list[i3])
|
||||||
|
|
||||||
6
2020/01.test
Normal file
6
2020/01.test
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
1721
|
||||||
|
979
|
||||||
|
366
|
||||||
|
299
|
||||||
|
675
|
||||||
|
1456
|
||||||
1000
2020/02.input
Normal file
1000
2020/02.input
Normal file
File diff suppressed because it is too large
Load Diff
34
2020/02.py
Normal file
34
2020/02.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# with open('./2020/02.test') as input:
|
||||||
|
with open('./2020/02.input') as input:
|
||||||
|
input_list = input.read().split('\n')
|
||||||
|
|
||||||
|
working_list = []
|
||||||
|
for one_input in input_list:
|
||||||
|
one_output = {}
|
||||||
|
one_output['low'] = int(one_input.split(' ')[0].split('-')[0])
|
||||||
|
one_output['high'] = int(one_input.split(' ')[0].split('-')[1])
|
||||||
|
one_output['letter'] = one_input.split(':')[0].split(' ')[1]
|
||||||
|
one_output['password'] = one_input.split(' ')[2]
|
||||||
|
|
||||||
|
working_list.append(one_output)
|
||||||
|
|
||||||
|
valid_count = 0
|
||||||
|
for one_input in working_list:
|
||||||
|
num_target = one_input['password'].count(one_input['letter'])
|
||||||
|
|
||||||
|
if num_target >= one_input['low'] and num_target <= one_input['high']:
|
||||||
|
valid_count += 1
|
||||||
|
|
||||||
|
print(valid_count)
|
||||||
|
|
||||||
|
valid_count = 0
|
||||||
|
for one_input in working_list:
|
||||||
|
temp_check = 0
|
||||||
|
if one_input['password'][one_input['low'] - 1] == one_input['letter']:
|
||||||
|
temp_check += 1
|
||||||
|
if one_input['password'][one_input['high'] - 1] == one_input['letter']:
|
||||||
|
temp_check += 1
|
||||||
|
|
||||||
|
if temp_check == 1:
|
||||||
|
valid_count += 1
|
||||||
|
print(valid_count)
|
||||||
3
2020/02.test
Normal file
3
2020/02.test
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