File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ (ns advent-of-code.2016.24
2+ (:require [advent-of-code.utils :as u]
3+ [advent-of-code.points :as p]
4+ [advent-of-code.vectors :refer [evict-at]]))
5+
6+ (def path (u/get-input 2016 24 ))
7+ (def tpath (u/test-path 2016 24 ))
8+
9+ ; Incredibly slow, but I'm lazy today, and it works, so why bother ¯\_(ツ)_/¯
10+ (defn run [path part2?]
11+ (let [grid (->> (u/read-file-list path identity)
12+ p/->grid)
13+ start (ffirst (filter #(#{\0 } (second %)) grid))
14+ targets (->> (filter #(#{\1 \2 \3 \4 \5 \6 \7 \8 \9 } (second %)) grid)
15+ (mapv first))
16+ min-path (fn bfs [curr open]
17+ (if (empty? open)
18+ (if part2? (p/a-star-score grid curr start) 0 )
19+ (apply min (map (fn [i] (+ (p/a-star-score grid curr (open i))
20+ (bfs (open i) (evict-at open i)))) (range (count open))))))]
21+ (time (min-path start targets))))
22+
23+ (comment
24+
25+ (run path false )
26+ (run path true )
27+ ;
28+ )
You can’t perform that action at this time.
0 commit comments