aboutsummaryrefslogtreecommitdiff
path: root/2022/Day01/part-one.cl
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2022-12-02 12:10:03 +0200
committerSyndamia <kamen@syndamia.com>2022-12-02 12:10:03 +0200
commit15aab5d23ae97f4dd498bf3460be1ef22e31f3b5 (patch)
treec34cc19177f08a72c513af478c33894bceb1f9da /2022/Day01/part-one.cl
parentc8f083a44f655b00c2aa229cff25a7aef2432699 (diff)
downloadadvent-of-code-15aab5d23ae97f4dd498bf3460be1ef22e31f3b5.tar
advent-of-code-15aab5d23ae97f4dd498bf3460be1ef22e31f3b5.tar.gz
advent-of-code-15aab5d23ae97f4dd498bf3460be1ef22e31f3b5.zip
[2022] Updated names of folders
Diffstat (limited to '2022/Day01/part-one.cl')
-rw-r--r--2022/Day01/part-one.cl22
1 files changed, 22 insertions, 0 deletions
diff --git a/2022/Day01/part-one.cl b/2022/Day01/part-one.cl
new file mode 100644
index 0000000..34644c6
--- /dev/null
+++ b/2022/Day01/part-one.cl
@@ -0,0 +1,22 @@
+(defvar *prog-input*)
+
+(let ((ui (read-line)))
+ (if (equal ui "")
+ (setq *prog-input* *standard-input*)
+ (setq *prog-input* (open ui))))
+
+(let
+ ((cal (read-line *prog-input* NIL)) (maxsum 0) (csum 0))
+
+ (loop until (or (equal cal "end") (not cal)) do
+ (if (equal cal "")
+ (setq csum 0)
+ (setq csum (+ csum (parse-integer cal))))
+ (if (> csum maxsum)
+ (setq maxsum csum))
+ (setq cal (read-line *prog-input* NIL)))
+
+ (print maxsum))
+
+(if (not (eq *prog-input* *standard-input*))
+ (close *prog-input*))