diff --git a/.dir-locals.el b/.dir-locals.el deleted file mode 100644 index 9f73a07..0000000 --- a/.dir-locals.el +++ /dev/null @@ -1,4 +0,0 @@ -;;; Directory Local Variables -*- no-byte-compile: t -*- -;;; For more information see (info "(emacs) Directory Variables") - -((lisp-mode . ((inferior-lisp-program . "sbcl")))) diff --git a/.gitignore b/.gitignore index b9fa3c1..31c4698 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ *.x86f *~ .#* +*.~undo-tree~ \ No newline at end of file diff --git a/src/2018/day07.lisp b/src/2018/day07.lisp index 98a5f5d..04648b9 100644 --- a/src/2018/day07.lisp +++ b/src/2018/day07.lisp @@ -37,64 +37,14 @@ Step F must be finished before step E can begin.")) if (not (member p produced)) collect p)))) -(defun dependency-lessp (a b) - (string-lessp (second a) (second b))) - -(defun next-ready-rules (dependencies done) - (let ((available (append done (steps-without-dependencies dependencies)))) - (sort - (loop for d in dependencies - if (member (first d) available) - if (not (member (second d) available)) - if (prerequisites-availablep available (second d) dependencies) - collect d) - #'dependency-lessp))) - - -(defun merge-steps (steps rule) - (if (member (first rule) steps) - (append steps (list (second rule))) - (append steps rule))) - -(defun number-steps (dependencies) - (length - (remove-duplicates - (append - (map 'list #'first dependencies) - (map 'list #'second dependencies))))) - -(defparameter *counter* 0) -(setf *counter* 0) - -(defparameter *path* '()) - -(defun assy-order (dependencies) - (let ((todo (queues:make-queue :simple-queue)) - (target-length (number-steps dependencies)) - (path '())) - (loop for step in (steps-without-dependencies dependencies) - do (queues:qpush todo (list step))) - (queues:print-queue todo) - (loop - do (setf path (queues:qpop todo)) - do (setf *path* path) - do (incf *counter*) - while (and path (not (= target-length (length path)))) - do (loop - for rule in (next-ready-rules dependencies path) - for tgt = (second rule) - for npath = (append path (list tgt)) - do (queues:qpush todo npath))) - path)) -(defun print-thread-info () - (let* ((curr-thread sb-thread:*current-thread*) - (curr-thread-name (sb-thread:thread-name curr-thread)) - (all-threads (sb-thread:list-all-threads))) - (format t "Current thread: ~a~%~%" curr-thread) - (format t "Current thread name: ~a~%~%" curr-thread-name) - (format t "All threads:~% ~{~a~%~}~%" all-threads)) - nil) + + + + + + + diff --git a/src/main.lisp b/src/main.lisp index 52a95e9..ee75f98 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -61,3 +61,12 @@ (if val val (setf (gethash key *input-data-cache*) (fetch-input-data year day))))) + +(defun print-thread-info () + (let* ((curr-thread sb-thread:*current-thread*) + (curr-thread-name (sb-thread:thread-name curr-thread)) + (all-threads (sb-thread:list-all-threads))) + (format t "Current thread: ~a~%~%" curr-thread) + (format t "Current thread name: ~a~%~%" curr-thread-name) + (format t "All threads:~% ~{~a~%~}~%" all-threads)) + nil)