From da5530cdefca207918dbc95961996e967fed33c5 Mon Sep 17 00:00:00 2001 From: Peter Hudec Date: Mon, 13 Dec 2021 07:59:07 +0100 Subject: [PATCH] added day 01 --- 01/input01.txt | 200 ++++++++++++++++++++++++++++++++++++++++++ 01/input01_sample.txt | 6 ++ 01/solve01.py | 13 +++ 01/solve02.py | 13 +++ 4 files changed, 232 insertions(+) create mode 100644 01/input01.txt create mode 100644 01/input01_sample.txt create mode 100644 01/solve01.py create mode 100644 01/solve02.py diff --git a/01/input01.txt b/01/input01.txt new file mode 100644 index 0000000..cd5e9da --- /dev/null +++ b/01/input01.txt @@ -0,0 +1,200 @@ +1408 +1335 +1648 +1458 +1627 +1928 +1967 +1827 +1606 +1569 +1893 +1866 +1768 +1795 +1264 +1684 +1552 +1343 +1917 +1675 +1731 +1800 +1413 +1879 +1664 +1350 +1694 +1372 +1851 +1743 +1735 +833 +748 +1265 +1885 +1874 +2007 +1661 +1895 +1537 +1622 +1355 +762 +1533 +1771 +1966 +1978 +1572 +1833 +1969 +1805 +1820 +1536 +1911 +2009 +1817 +1268 +1998 +1759 +2008 +2002 +1187 +1896 +1850 +1734 +1849 +1589 +1302 +444 +1280 +1590 +1959 +902 +1709 +1932 +1277 +1561 +1301 +1831 +1286 +1693 +1927 +1467 +1384 +1662 +1401 +716 +1634 +1785 +1801 +1380 +1971 +1292 +1828 +185 +1560 +1322 +1787 +1545 +1395 +1445 +1807 +1750 +1867 +1433 +1894 +1821 +1983 +1578 +1669 +1610 +1549 +1556 +1346 +1616 +1999 +1925 +1387 +1659 +1457 +1237 +1808 +69 +1906 +1449 +1723 +1974 +1919 +1914 +1338 +1305 +1347 +1903 +1929 +1712 +1607 +1400 +197 +1575 +1282 +1296 +1737 +1396 +2003 +1453 +1660 +1646 +1991 +1565 +1416 +1995 +1784 +1367 +1420 +1593 +1654 +1306 +1916 +1797 +1594 +1471 +1405 +1698 +1541 +1900 +1963 +1696 +1574 +1853 +511 +1603 +1889 +1940 +1843 +1979 +272 +1726 +1294 +1877 +1441 +1697 +1644 +1956 +1689 +1665 +1631 +1717 +1781 +1450 +1618 +1317 +1799 +1950 +1722 +1960 +1628 +1941 +1977 +1775 +1529 \ No newline at end of file diff --git a/01/input01_sample.txt b/01/input01_sample.txt new file mode 100644 index 0000000..0bb977d --- /dev/null +++ b/01/input01_sample.txt @@ -0,0 +1,6 @@ +1721 +979 +366 +299 +675 +1456 \ No newline at end of file diff --git a/01/solve01.py b/01/solve01.py new file mode 100644 index 0000000..8add046 --- /dev/null +++ b/01/solve01.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python + + +report = dict() + +with open("input01.txt","r") as f: + for line in f: + num1 = int(line) + report[num1] = True + num2 = 2020 - num1 + if report.get(num2, False): + print(num1*num2) + break diff --git a/01/solve02.py b/01/solve02.py new file mode 100644 index 0000000..4228941 --- /dev/null +++ b/01/solve02.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python + +from itertools import permutations + +report = [] + +with open("input01.txt","r") as f: + report = [int(i) for i in f.readlines()] + +for p in permutations(report, 3): + if sum(p) == 2020: + print(p[0]*p[1]*p[2]) + break; \ No newline at end of file