42 lines
1.2 KiB
Common Lisp
Executable file
42 lines
1.2 KiB
Common Lisp
Executable file
;; #!/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))
|
|
;; )
|