aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2022-12-06 17:48:31 +0200
committerSyndamia <kamen@syndamia.com>2022-12-06 17:48:31 +0200
commit7f5f04976dbd5c21383797c49e89d69939babeb3 (patch)
treee2a58b70919778823555d221d6e4bbe54aba83bc
parent58a5079e090f7e55371479b841818cf188877b03 (diff)
downloadadvent-of-code-7f5f04976dbd5c21383797c49e89d69939babeb3.tar
advent-of-code-7f5f04976dbd5c21383797c49e89d69939babeb3.tar.gz
advent-of-code-7f5f04976dbd5c21383797c49e89d69939babeb3.zip
[2022/D06] Rewrote second task, following update to senzill
-rw-r--r--2022/Day06/part-two.cl30
1 files changed, 6 insertions, 24 deletions
diff --git a/2022/Day06/part-two.cl b/2022/Day06/part-two.cl
index 62c170d..6389c90 100644
--- a/2022/Day06/part-two.cl
+++ b/2022/Day06/part-two.cl
@@ -1,24 +1,13 @@
;;; https://gitlab.com/Syndamia/senzill
(require :senzill)
(use-package :senzill.collections)
-
-;;; After loading this file, if you enter a blank line, code will work on each
-;;; line of input, until "end" is typed.
-;;; Otherwise, the input is taken as a filename and code will be executed
-;;; over each line in the file until EOF.
-
-(defvar *prog-input*)
-(let ((ui (read-line)))
- (if (equal ui "")
- (setq *prog-input* *standard-input*)
- (setq *prog-input* (open ui))))
+(use-package :senzill.io)
(defconstant +process-characters+ 14)
-(let
- ((inpt (read-line *prog-input* NIL)) (met '()) (sop -1))
-
- (loop until (or (string= inpt "end") (not inpt)) do
+(ask-for-stream (prog-input)
+ (let ((met '()) (sop -1))
+ (doread-lines (inpt :read-line-options (prog-input NIL))
(loop for i from 0 to (- (length inpt) 1)
until (> sop 0) do
@@ -26,12 +15,5 @@
(pop-back met))
(push (char inpt i) met)
(if (= (length met) +process-characters+)
- (setq sop (+ 1 i))))
-
- (setq inpt (read-line *prog-input* NIL)))
-
- (print sop))
-
-(if (not (eq *prog-input* *standard-input*))
- (close *prog-input*))
-
+ (setq sop (+ 1 i)))))
+ (print sop)))