Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 200 additions & 0 deletions day-01/input/david.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
1953
2006
1926
1946
1722
1776
1924
1860
2002
1920
1911
1750
1657
2005
1829
1693
1717
1844
1642
1875
1741
1755
1688
1700
1842
1598
1942
1599
1710
1627
1915
1913
1814
1852
1564
1877
1569
1669
2009
1807
1906
1838
1794
1839
1783
1851
1716
1705
1914
1786
1812
1616
1997
1718
1984
1751
1810
1928
1701
1632
1948
616
1981
1878
1903
1690
1836
1631
1649
1562
1707
457
1861
1843
979
1605
1652
1596
1730
1560
1886
1802
1614
1929
1570
1907
1950
1969
1629
1769
1575
1932
1983
1781
1954
1663
1644
2004
1772
1044
794
1882
1808
1831
1635
1976
1834
1855
1721
1372
1777
1702
1945
1788
1989
1819
1874
1720
787
1806
1966
1949
1694
1752
1887
1687
1943
1665
1774
1645
1900
1661
1968
1706
1586
1977
1691
1991
1870
1865
1764
1967
1714
1594
1429
1647
1858
1805
1561
1895
1559
1988
1565
1799
1862
1578
1664
1816
1628
1960
1775
1746
1324
1835
1658
1918
1671
1957
1864
696
1679
254
1017
1622
1601
1592
1782
1767
1825
1655
1784
1896
1965
1600
1963
1840
1749
1970
1980
1936
1685
1790
1902
1729
2001
1638
1986
1879
1847
1866
14 changes: 14 additions & 0 deletions day-01/part-1/david.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from tool.runners.python import SubmissionPy


class DavidSubmission(SubmissionPy):

def run(self, s):
# :param s: input in string format
# :return: solution flag
# Your code goes here
entries = {int(x) for x in s.split("\n")}
for i in entries:
j = 2020-i
if j in entries:
return i*j
20 changes: 20 additions & 0 deletions day-01/part-2/david.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from tool.runners.python import SubmissionPy


class DavidSubmission(SubmissionPy):

def run(self, s):
# :param s: input in string format
# :return: solution flag
# Your code goes here
entries = [int(x) for x in s.split("\n")]
assert(all(x >= 0 for x in entries))

for idx_i, i in enumerate(entries):
for idx_j, j in enumerate(entries[idx_i+1:]):
if i+j > 2020:
# no need to find the 3rd item
continue
for k in entries[idx_j+1:]:
if i+j+k == 2020:
return i*j*k