From 1d00f7c69ed700b697a3f8c02f4f8e410d92776a Mon Sep 17 00:00:00 2001 From: Jan <26145882+imverum@users.noreply.github.com> Date: Tue, 1 Dec 2020 15:37:36 +0100 Subject: [PATCH] add coed --- day_1/input.txt | 200 ++++++++++++++++++++++++++++++++++++++++++++++++ day_1/task_1.js | 11 +++ day_1/task_2.js | 13 ++++ 3 files changed, 224 insertions(+) create mode 100644 day_1/input.txt create mode 100644 day_1/task_1.js create mode 100644 day_1/task_2.js diff --git a/day_1/input.txt b/day_1/input.txt new file mode 100644 index 0000000..a679df5 --- /dev/null +++ b/day_1/input.txt @@ -0,0 +1,200 @@ +1254 +1313 +1456 +1782 +1742 +1391 +1273 +1286 +1373 +1891 +1188 +1994 +1887 +1816 +1984 +961 +1428 +1105 +1123 +1699 +1154 +1953 +1977 +1450 +1696 +1068 +1241 +1926 +1228 +1591 +1789 +1966 +1508 +1193 +1190 +1654 +444 +1282 +1169 +1165 +1778 +1669 +1570 +1671 +1845 +1208 +1728 +1798 +847 +1300 +1817 +1200 +1297 +1658 +1296 +1571 +1991 +1305 +1314 +1903 +1472 +1359 +1506 +1999 +1877 +1168 +1137 +1288 +1083 +1656 +413 +1430 +1408 +1397 +1846 +1218 +684 +1234 +2007 +900 +1604 +1460 +1848 +1693 +1324 +1401 +1968 +1918 +1975 +1665 +1413 +1874 +1852 +1521 +1753 +1229 +1940 +1650 +1976 +1235 +1130 +1927 +1365 +1908 +1441 +1302 +1986 +1449 +1692 +1944 +1277 +1312 +1826 +1231 +1289 +1814 +1170 +1606 +1608 +1773 +1883 +1936 +1626 +1497 +1860 +1673 +1295 +2005 +1481 +1995 +1734 +1646 +1557 +1298 +1174 +1894 +1309 +1240 +1982 +1414 +1799 +1620 +1863 +1220 +1642 +508 +1146 +1187 +1253 +1284 +1952 +1527 +1610 +1333 +1221 +1362 +1457 +1721 +1493 +1330 +156 +1647 +1841 +1724 +2000 +1398 +1745 +1985 +1269 +1722 +2001 +1923 +1395 +1094 +1140 +1958 +1239 +1336 +1588 +1338 +1750 +1757 +1444 +1822 +1335 +1941 +1865 +1767 +1881 +1499 +1157 +1990 +1210 +1779 +1201 +1784 +1961 +1476 +1861 +1468 \ No newline at end of file diff --git a/day_1/task_1.js b/day_1/task_1.js new file mode 100644 index 0000000..65a6a49 --- /dev/null +++ b/day_1/task_1.js @@ -0,0 +1,11 @@ +const fs = require('fs'); +const file = fs.readFileSync('./input.txt').toString('utf-8'); +const arr = file.split('\n'); + +arr.forEach(num => { + arr.forEach(num2 => { + if (Number(num) + Number(num2) == 2020) { + console.log(`Found match: ${num} + ${num2} (${num * num2})`); + } + }); +}); \ No newline at end of file diff --git a/day_1/task_2.js b/day_1/task_2.js new file mode 100644 index 0000000..6904256 --- /dev/null +++ b/day_1/task_2.js @@ -0,0 +1,13 @@ +const fs = require('fs'); +const file = fs.readFileSync('./input.txt').toString('utf-8'); +const arr = file.split('\n'); + +arr.forEach(num => { + arr.forEach(num2 => { + arr.forEach(num3 => { + if (Number(num) + Number(num2) + Number(num3) == 2020) { + console.log(`Found match: ${num} + ${num2} + ${num3} (${num * num2 * num3})`); + } + }); + }); +}); \ No newline at end of file