From 7c19b98694ce2fc3e9433cabc59135b7d693c103 Mon Sep 17 00:00:00 2001 From: Sebastian Seedorf Date: Tue, 1 Dec 2020 22:14:16 +0100 Subject: [PATCH] Day 1 --- .idea/.gitignore | 8 ++ .idea/misc.xml | 6 ++ .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 ++ day01/input.txt | 200 ++++++++++++++++++++++++++++++++++++++++++++ day01/part1.py | 18 ++++ day01/part2.py | 14 ++++ python-aoc-2020.iml | 16 ++++ 8 files changed, 276 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 day01/input.txt create mode 100644 day01/part1.py create mode 100644 day01/part2.py create mode 100644 python-aoc-2020.iml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..f8cc37f --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..fdf3dad --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/day01/input.txt b/day01/input.txt new file mode 100644 index 0000000..c1c2661 --- /dev/null +++ b/day01/input.txt @@ -0,0 +1,200 @@ +1801 +1324 +1924 +1848 +1735 +1721 +1948 +1667 +1832 +1773 +1972 +1777 +1866 +1850 +1786 +1617 +1806 +1923 +789 +1645 +1530 +1989 +1720 +1681 +1807 +1716 +1935 +1944 +1878 +1859 +1602 +1154 +1824 +1993 +1952 +1849 +1695 +523 +1845 +1879 +1744 +1374 +1567 +1725 +1986 +2006 +1739 +1751 +1709 +1800 +2008 +1715 +1728 +1677 +1388 +1815 +1750 +1827 +1737 +1819 +1916 +1909 +1726 +1753 +1899 +1981 +1558 +1852 +1762 +551 +1881 +1891 +1957 +1976 +1383 +1847 +1968 +1736 +1828 +1851 +1975 +1794 +1785 +1837 +1979 +1798 +1789 +1534 +1877 +1724 +1843 +1812 +1743 +1951 +1900 +1887 +1766 +1991 +1839 +1700 +1858 +1864 +2004 +1870 +1985 +1919 +1466 +1754 +1964 +946 +1907 +1942 +1911 +321 +1930 +1854 +1644 +1757 +1719 +1741 +1853 +1706 +1659 +1945 +1821 +1950 +1761 +1838 +1770 +1927 +1447 +1803 +2000 +2010 +1765 +1691 +1742 +1936 +1929 +1902 +1539 +1816 +1553 +1982 +1813 +1896 +1772 +267 +1829 +1912 +1787 +1782 +1763 +1461 +1883 +1894 +2005 +1758 +1717 +1749 +1733 +1775 +1767 +1705 +1959 +1903 +1880 +2003 +1544 +1732 +1833 +1926 +1980 +1946 +1978 +1710 +1831 +1906 +1922 +1861 +1694 +1875 +307 +1920 +1934 +1966 +1804 +1799 +1548 +1871 +1769 +1997 +1639 +1830 +917 +1797 +1672 +1921 +1965 +1662 diff --git a/day01/part1.py b/day01/part1.py new file mode 100644 index 0000000..555d749 --- /dev/null +++ b/day01/part1.py @@ -0,0 +1,18 @@ +items = [int(x.strip()) for x in open("input.txt")] + +lows = [] +highs = [] + +for item in items: + if item < 1010: + lows.append(item) + else: + highs.append(item) + +print(lows) +print(highs) + +for low in lows: + for high in highs: + if low + high == 2020: + print("Found {} and {}: Sum={} Product={}".format(low, high, low+high, low*high)) diff --git a/day01/part2.py b/day01/part2.py new file mode 100644 index 0000000..e920056 --- /dev/null +++ b/day01/part2.py @@ -0,0 +1,14 @@ +import math +from itertools import combinations + +items = [int(x.strip()) for x in open("input.txt")] + +COUNT = 3 + +for vals in combinations(items, 3): + if sum(vals) == 2020: + print("Found {} and {} and {}: Sum={} Product={}".format( + *vals, + sum(vals), + math.prod(vals) + )) diff --git a/python-aoc-2020.iml b/python-aoc-2020.iml new file mode 100644 index 0000000..1e36f4d --- /dev/null +++ b/python-aoc-2020.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file