aboutsummaryrefslogtreecommitdiff
path: root/2022/Day10/part-two.cl
diff options
context:
space:
mode:
Diffstat (limited to '2022/Day10/part-two.cl')
-rw-r--r--2022/Day10/part-two.cl27
1 files changed, 27 insertions, 0 deletions
diff --git a/2022/Day10/part-two.cl b/2022/Day10/part-two.cl
new file mode 100644
index 0000000..5ce1b78
--- /dev/null
+++ b/2022/Day10/part-two.cl
@@ -0,0 +1,27 @@
+;;; 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 0) (check-on 40) (check-max 241) (line-buff ""))
+
+ (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 (print line-buff)
+ (force-output)
+ (setf line-buff "")
+ (if (< check-on check-max)
+ (+= check-on 40)
+ (setf check-on -1))
+ do (setf line-buff (concatenate 'string
+ line-buff
+ (if (or (= (mod cycles 40) (- X 1)) (= (mod cycles 40) X) (= (mod cycles 40) (+ X 1)))
+ "#"
+ ".")))
+ (++1 cycles)
+ if (= i 2)
+ do (+= X (parse-integer inpt :start 5))))
+ (print line-buff)))