aboutsummaryrefslogtreecommitdiff
path: root/2022/Day10/part-one.cl
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2022-12-10 09:43:46 +0200
committerSyndamia <kamen@syndamia.com>2022-12-10 09:43:53 +0200
commit92bd65ac086522ddea27f556085671040f8d7378 (patch)
tree4a6f58cf81066ace4e88846ccc00d8e5ae8f0e76 /2022/Day10/part-one.cl
parentbd16b90f12e03e85a62232d705824430cf64fd23 (diff)
downloadadvent-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.cl21
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)))