This commit is contained in:
Hane 2023-12-12 17:23:28 +01:00
commit 4c57ab57f3
3 changed files with 1046 additions and 0 deletions

42
src/aoc1.lisp Executable file
View file

@ -0,0 +1,42 @@
;; #!/bin/sbcl --script
;; (defun load-user-file (file)
;; (interactive "f")
;; "Load a file in current user's configuration directory"
;; (load-file (expand-file-name file user-init-dir))
;; )
(import 'ppcre)
(with-open-file (file "aoc1input.txt")
(let((num 0) (lineNum 0) (finding nil))
(loop for line = (read-line file nil)
while line do ;(
(setq finding (ppcre:all-matches-as-strings "\\d" line ))
(setq lineNum (parse-integer (concatenate 'string (first finding) (nth 0 (last finding)) )))
(setq num (+ num lineNum))
(setq lineNum 0)
;)
(print num)
))
;; format t "~a~%" line))
)
;; (with-open-file (file "aoc1test.txt")
;; (let((num 0) (lineNum 0) (finding nil))
;; (loop for line = (read-line file nil)
;; while line do ;(
;; (setq finding (map 'list #'parse-integer (ppcre:all-matches-as-strings "\\d" line )))
;; (setq lineNum (+ (nth 0 (last finding)) (first finding)))
;; (setq num (+ num lineNum))
;; (setq lineNum 0)
;; ;)
;; (print num)
;; ))
;; ;; format t "~a~%" line))
;; )
;; (let ((in (open "/some/file/name.txt" :if-does-not-exist nil)))
;; (when in
;; (close in))
;; )

1000
src/aoc1input.txt Normal file

File diff suppressed because it is too large Load diff

4
src/aoc1test.txt Normal file
View file

@ -0,0 +1,4 @@
1abc2
pqr3stu8vwx
a1b2c3d4e5f
treb7uchet