diff options
| author | Syndamia <kamen@syndamia.com> | 2022-12-10 09:43:46 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2022-12-10 09:43:53 +0200 |
| commit | 92bd65ac086522ddea27f556085671040f8d7378 (patch) | |
| tree | 4a6f58cf81066ace4e88846ccc00d8e5ae8f0e76 /2022/Day10/part-one.cl | |
| parent | bd16b90f12e03e85a62232d705824430cf64fd23 (diff) | |
| download | advent-of-code-92bd65ac086522ddea27f556085671040f8d7378.tar advent-of-code-92bd65ac086522ddea27f556085671040f8d7378.tar.gz advent-of-code-92bd65ac086522ddea27f556085671040f8d7378.zip | |
[2022/D10] Solved tasks from today
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))) |
