Initial commit
This commit is contained in:
commit
f242d2b0df
420 changed files with 62521 additions and 0 deletions
16
2019/day01/day01.lisp
Normal file
16
2019/day01/day01.lisp
Normal file
|
@ -0,0 +1,16 @@
|
|||
(defparameter *input-file* #P"input.txt")
|
||||
(defparameter *input* (uiop:read-file-lines *input-file*))
|
||||
|
||||
(defun part1 ()
|
||||
(loop for line in *input*
|
||||
sum (- (floor (/ (parse-integer line) 3)) 2)))
|
||||
|
||||
(defun total-fuel-requirements (total-fuel fuel)
|
||||
(let ((new-fuel (max 0 (- (floor (/ fuel 3)) 2))))
|
||||
(if (= new-fuel 0)
|
||||
(+ total-fuel fuel)
|
||||
(total-fuel-requirements (+ total-fuel fuel) new-fuel))))
|
||||
|
||||
(defun part2 ()
|
||||
(loop for line in *input*
|
||||
sum (total-fuel-requirements 0 (- (floor (/ (parse-integer line) 3)) 2))))
|
Loading…
Add table
Add a link
Reference in a new issue