day1
This commit is contained in:
commit
10a569faed
1
aoclib/__init__.py
Normal file
1
aoclib/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from .inputs import *
|
||||
18
aoclib/inputs.py
Normal file
18
aoclib/inputs.py
Normal file
@ -0,0 +1,18 @@
|
||||
import os
|
||||
|
||||
BASE_PATH = os.path.dirname(os.path.dirname(__file__))
|
||||
INPUTS_PATH = os.path.join(BASE_PATH, 'inputs')
|
||||
|
||||
|
||||
def getInputLineAsArray(day, return_type=None):
|
||||
"""
|
||||
get input for day x as array, each line representing one array entry
|
||||
when type is given, each entry will be converted to the specified type
|
||||
"""
|
||||
with open(os.path.join(INPUTS_PATH, str(day)), "r") as f:
|
||||
input_array = f.readlines()
|
||||
|
||||
if return_type:
|
||||
return [return_type(i) for i in input_array]
|
||||
else:
|
||||
return input_array
|
||||
13
day1.py
Normal file
13
day1.py
Normal file
@ -0,0 +1,13 @@
|
||||
import aoclib
|
||||
import sys
|
||||
|
||||
#my_input = [1721, 979, 366, 299, 675, 1456] # debug input
|
||||
my_input = aoclib.getInputLineAsArray(1, int)
|
||||
|
||||
while len(my_input) > 0:
|
||||
try_value = my_input.pop()
|
||||
for value in my_input:
|
||||
if try_value + value == 2020:
|
||||
print(try_value * value)
|
||||
sys.exit(0)
|
||||
|
||||
16
day1_2.py
Normal file
16
day1_2.py
Normal file
@ -0,0 +1,16 @@
|
||||
import aoclib
|
||||
import sys
|
||||
|
||||
#my_input = [1721, 979, 366, 299, 675, 1456] # debug input
|
||||
my_input = aoclib.getInputLineAsArray(1, int)
|
||||
|
||||
while len(my_input) > 0:
|
||||
try_value = my_input.pop()
|
||||
for value_1 in my_input:
|
||||
for value_2 in my_input:
|
||||
if value_1 == value_2:
|
||||
continue
|
||||
if try_value + value_1 + value_2 == 2020:
|
||||
print(try_value * value_1 * value_2)
|
||||
sys.exit(0)
|
||||
|
||||
200
inputs/1
Normal file
200
inputs/1
Normal file
@ -0,0 +1,200 @@
|
||||
1789
|
||||
1818
|
||||
1729
|
||||
1578
|
||||
1927
|
||||
751
|
||||
1772
|
||||
1521
|
||||
1850
|
||||
1438
|
||||
1855
|
||||
1334
|
||||
1878
|
||||
1290
|
||||
1678
|
||||
1847
|
||||
1495
|
||||
1538
|
||||
1403
|
||||
1797
|
||||
1906
|
||||
1770
|
||||
1963
|
||||
1370
|
||||
1684
|
||||
1328
|
||||
1544
|
||||
1528
|
||||
1871
|
||||
2010
|
||||
1999
|
||||
1347
|
||||
1760
|
||||
1903
|
||||
1860
|
||||
1468
|
||||
1511
|
||||
1477
|
||||
1668
|
||||
1979
|
||||
1358
|
||||
1298
|
||||
1493
|
||||
1459
|
||||
1382
|
||||
2001
|
||||
1394
|
||||
1681
|
||||
1515
|
||||
1948
|
||||
1991
|
||||
1775
|
||||
1661
|
||||
1786
|
||||
1966
|
||||
1506
|
||||
1853
|
||||
1373
|
||||
1454
|
||||
1462
|
||||
1830
|
||||
1964
|
||||
1442
|
||||
1455
|
||||
2008
|
||||
1854
|
||||
1763
|
||||
1758
|
||||
1751
|
||||
1460
|
||||
1630
|
||||
1487
|
||||
1360
|
||||
1793
|
||||
1590
|
||||
1940
|
||||
1388
|
||||
1313
|
||||
1408
|
||||
1429
|
||||
1725
|
||||
1397
|
||||
1941
|
||||
1974
|
||||
1788
|
||||
1473
|
||||
1913
|
||||
664
|
||||
1989
|
||||
1490
|
||||
1778
|
||||
1726
|
||||
1366
|
||||
2005
|
||||
1449
|
||||
1924
|
||||
1926
|
||||
1769
|
||||
1314
|
||||
1636
|
||||
1780
|
||||
1546
|
||||
1647
|
||||
1856
|
||||
320
|
||||
396
|
||||
1595
|
||||
1867
|
||||
1602
|
||||
1699
|
||||
1367
|
||||
1876
|
||||
1662
|
||||
1686
|
||||
1581
|
||||
1697
|
||||
1938
|
||||
1400
|
||||
720
|
||||
1808
|
||||
1625
|
||||
1439
|
||||
1734
|
||||
2003
|
||||
1718
|
||||
1879
|
||||
1864
|
||||
1811
|
||||
1309
|
||||
721
|
||||
1607
|
||||
1814
|
||||
1484
|
||||
1869
|
||||
1736
|
||||
1507
|
||||
1437
|
||||
1894
|
||||
1561
|
||||
2004
|
||||
269
|
||||
1942
|
||||
1915
|
||||
1767
|
||||
1562
|
||||
1364
|
||||
1783
|
||||
1863
|
||||
1601
|
||||
1323
|
||||
182
|
||||
1985
|
||||
1722
|
||||
1545
|
||||
1774
|
||||
1552
|
||||
1742
|
||||
1790
|
||||
1874
|
||||
1583
|
||||
1308
|
||||
1441
|
||||
1463
|
||||
1503
|
||||
1447
|
||||
1540
|
||||
1953
|
||||
1371
|
||||
1331
|
||||
1688
|
||||
1905
|
||||
1815
|
||||
1799
|
||||
811
|
||||
1446
|
||||
1374
|
||||
1936
|
||||
1665
|
||||
1433
|
||||
1551
|
||||
1806
|
||||
1674
|
||||
1784
|
||||
1596
|
||||
1704
|
||||
1393
|
||||
1691
|
||||
1567
|
||||
1335
|
||||
593
|
||||
1509
|
||||
1986
|
||||
1297
|
||||
1419
|
||||
1418
|
||||
1339
|
||||
1745
|
||||
1930
|
||||
1514
|
||||
1706
|
||||
Loading…
Reference in New Issue
Block a user