full aoc8 fuck you
This commit is contained in:
parent
1c24854526
commit
d530bda461
7 changed files with 1269 additions and 0 deletions
40
src/aoc8.lisp
Normal file
40
src/aoc8.lisp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
;; #!/bin/sbcl --script
|
||||
(with-open-file (file "aoc8input.txt")
|
||||
(let( (key "AAA") (steps 0) (goal-to-be-reached nil) (direction-line "") (route-hash (make-hash-table :test #'equalp :size 800)) )
|
||||
;;Prep work
|
||||
(setf direction-line (read-line file nil))
|
||||
;;(setf direction-line (subseq temp-first-line (+ 2 (position #\: temp-first-line :test #'equalp)) (length temp-first-line) ))
|
||||
;;(setf yet-to-translate (seed-list manipulated-line))
|
||||
;;(print yet-to-translate)
|
||||
;;(print translated)
|
||||
(print "----")
|
||||
(read-line file nil)
|
||||
|
||||
(loop for line = (read-line file nil)
|
||||
with key = ""
|
||||
with left-value = ""
|
||||
with right-value = ""
|
||||
with cell = nil
|
||||
while line
|
||||
do
|
||||
(setf key (subseq line 0 (- (position #\= line :test #'equalp) 1) ))
|
||||
(setf left-value (subseq line (+ 1 (position #\( line :test #'equalp)) (position #\, line :test #'equalp) ))
|
||||
(setf right-value (subseq line (+ 2 (position #\, line :test #'equalp)) (position #\) line :test #'equalp) ))
|
||||
(setf (gethash key route-hash) (cons left-value right-value))
|
||||
)
|
||||
(loop for key being the hash-keys of route-hash
|
||||
using (hash-value value)
|
||||
do (format t "~%The value associated with the key ~a is ~A" key value))
|
||||
|
||||
(loop while (not goal-to-be-reached)
|
||||
do
|
||||
(loop for c across direction-line
|
||||
while (not goal-to-be-reached)
|
||||
do
|
||||
(print key)
|
||||
(incf steps)
|
||||
(if(char= c #\L)
|
||||
(setf key (car(gethash key route-hash)))
|
||||
(setf key (cdr(gethash key route-hash))))
|
||||
(if (string= key "ZZZ") (setf goal-to-be-reached t)) ))
|
||||
(print steps)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue