20 files changed, 240 insertions(+), 10 deletions(-)
R .gitignore => 2019/.gitignore
R days/day1.lisp => 2019/days/day1.lisp
R days/day3.lisp => 2019/days/day3.lisp
R days/day4.lisp => 2019/days/day4.lisp
R days/day6.lisp => 2019/days/day6.lisp
R days/day7.lisp => 2019/days/day7.lisp
R days/day8.lisp => 2019/days/day8.lisp
R inputs/day1-input.txt => 2019/inputs/day1-input.txt
R inputs/day3-input.txt => 2019/inputs/day3-input.txt
R inputs/day3-input2.txt => 2019/inputs/day3-input2.txt
R inputs/day6-input.txt => 2019/inputs/day6-input.txt
R inputs/day7-input.txt => 2019/inputs/day7-input.txt
R inputs/day7-input2.txt => 2019/inputs/day7-input2.txt
R inputs/day8-input.txt => 2019/inputs/day8-input.txt
R intcode.lisp => 2019/intcode.lisp
R package.lisp => 2019/package.lisp
A 2020/days/day1.lisp
A 2020/inputs/day1.txt
A 2020/package.lisp
M advent.asd
R .gitignore => 2019/.gitignore +0 -0
R days/day1.lisp => 2019/days/day1.lisp +1 -1
@@ 18,4 18,4 @@
(let ((fuels (read-fuel-file filename)))
(reduce #'+ (mapcar #'add-fuels fuels))))
-(fuel-required "./inputs/day1-input.txt")
+(fuel-required "./2019/inputs/day1-input.txt")
R days/day3.lisp => 2019/days/day3.lisp +0 -0
R days/day4.lisp => 2019/days/day4.lisp +0 -0
R days/day6.lisp => 2019/days/day6.lisp +0 -0
R days/day7.lisp => 2019/days/day7.lisp +0 -0
R days/day8.lisp => 2019/days/day8.lisp +0 -0
R inputs/day1-input.txt => 2019/inputs/day1-input.txt +0 -0
R inputs/day3-input.txt => 2019/inputs/day3-input.txt +0 -0
R inputs/day3-input2.txt => 2019/inputs/day3-input2.txt +0 -0
R inputs/day6-input.txt => 2019/inputs/day6-input.txt +0 -0
R inputs/day7-input.txt => 2019/inputs/day7-input.txt +0 -0
R inputs/day7-input2.txt => 2019/inputs/day7-input2.txt +0 -0
R inputs/day8-input.txt => 2019/inputs/day8-input.txt +0 -0
R intcode.lisp => 2019/intcode.lisp +0 -0
R package.lisp => 2019/package.lisp +0 -0
A 2020/days/day1.lisp => 2020/days/day1.lisp +23 -0
@@ 0,0 1,23 @@
+(in-package #:advent-2020)
+
+(defvar *day1-file* "2020/inputs/day1.txt")
+
+(defun slurp (filename)
+ (mapcar #'parse-integer (uiop:read-file-lines filename)))
+
+(defun is-it-2020?-part-1 ()
+ (let ((numbers (slurp *day1-file*)))
+ (dolist (numi numbers)
+ (dolist (numj numbers)
+ (unless (= numi numj)
+ (when (= 2020 (+ numi numj))
+ (return-from is-it-2020?-part-1 (* numi numj))))))))
+
+(defun is-it-2020?-part-2 ()
+ (let ((numbers (slurp *day1-file*)))
+ (dolist (numi numbers)
+ (dolist (numj numbers)
+ (dolist (numk numbers)
+ (unless (= numi numj numk)
+ (when (= 2020 (+ numi numj numk))
+ (return-from is-it-2020?-part-2 (* numi numj numk)))))))))
A 2020/inputs/day1.txt => 2020/inputs/day1.txt +200 -0
@@ 0,0 1,200 @@
+1956
+1994
+457
+1654
+2003
+1902
+1741
+1494
+1597
+1129
+1146
+1589
+1989
+1093
+1881
+1288
+1848
+1371
+1508
+1035
+1813
+1335
+1634
+1102
+1262
+1637
+1048
+1807
+1270
+1528
+1670
+1803
+1202
+1294
+1570
+1640
+1484
+1872
+1140
+1207
+1485
+1781
+1778
+1772
+1334
+1267
+1045
+1194
+1873
+1441
+1557
+1414
+1123
+1980
+1527
+1591
+1665
+1916
+1662
+1139
+1973
+1258
+1041
+1134
+1609
+1554
+1455
+1124
+1478
+1938
+1759
+1281
+1410
+1511
+930
+1319
+1302
+1827
+1216
+1404
+1460
+2002
+1590
+1817
+1341
+1631
+1608
+1382
+1158
+1594
+1049
+1804
+1555
+1753
+447
+1021
+1079
+609
+1766
+1327
+1851
+1052
+1737
+1175
+1043
+1945
+1573
+1113
+1724
+1203
+1856
+1682
+1623
+1135
+1015
+1423
+1412
+1315
+1375
+1895
+1351
+1530
+1758
+1445
+1518
+1819
+1567
+1305
+1919
+1952
+1432
+1099
+1476
+1883
+1871
+1900
+1442
+1393
+1214
+1283
+1538
+1391
+1008
+1109
+1621
+1876
+1998
+1032
+1324
+1927
+481
+1732
+1370
+1683
+1199
+1465
+1882
+1293
+1671
+1456
+1197
+1506
+1381
+1469
+1830
+1957
+1850
+1184
+1564
+1170
+1943
+1131
+1867
+1208
+1788
+1337
+1722
+1760
+1651
+1069
+1574
+1959
+1770
+66
+1190
+1606
+1899
+1054
+980
+1693
+1173
+1479
+1333
+1579
+1720
+1782
+1971
+1438
+1178
+1306
A 2020/package.lisp => 2020/package.lisp +2 -0
@@ 0,0 1,2 @@
+(defpackage :advent-2020
+ (:use :cl))
M advent.asd => advent.asd +14 -9
@@ 5,12 5,17 @@
:license "GPLv3"
:version "0.0.1"
:depends-on (:cl-ppcre :bordeaux-threads)
- :components ((:file "package")
- (:file "intcode")
- (:module "days"
- :components ((:file "day1")
- (:file "day3")
- (:file "day4")
- (:file "day6")
- (:file "day7")
- (:file "day8")))))
+ :components ((:module "2019"
+ :components ((:file "package")
+ (:file "intcode")
+ (:module "days"
+ :components ((:file "day1")
+ (:file "day3")
+ (:file "day4")
+ (:file "day6")
+ (:file "day7")
+ (:file "day8")))))
+ (:module "2020"
+ :components ((:file "package")
+ (:module "days"
+ :components ((:file "day1")))))))