diff options
Diffstat (limited to '2022/Day10/part-one.cl')
| -rw-r--r-- | 2022/Day10/part-one.cl | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/2022/Day10/part-one.cl b/2022/Day10/part-one.cl new file mode 100644 index 0000000..9b3ace6 --- /dev/null +++ b/2022/Day10/part-one.cl @@ -0,0 +1,21 @@ + +;;; https://gitlab.com/Syndamia/senzill +(require :senzill) +(use-package :senzill.math) +(use-package :senzill.collections) +(use-package :senzill.io) + +(ask-for-stream (prog-input) + (let ((X 1) (cycles 1) (check-on 20) (check-max 220) (signal-sum 0)) + + (doread-lines (inpt :read-line-options (prog-input NIL)) + (loop for i from 1 to (if (char= (char inpt 0) #\a) 2 1) + if (and (> check-on 0) (= cycles check-on)) + do (+= signal-sum (* X check-on)) + (if (< check-on check-max) + (+= check-on 40) + (setf check-on -1)) + if (= i 2) + do (+= X (parse-integer inpt :start 5)) + do (++1 cycles))) + (print signal-sum))) |
