day 5 WIP
This commit is contained in:
parent
e0509be163
commit
53c5b778c9
60
src/day5.clj
Normal file
60
src/day5.clj
Normal file
@ -0,0 +1,60 @@
|
||||
(ns day5
|
||||
(:require [clojure.string :as string]
|
||||
[helpers :refer [get-input]]))
|
||||
|
||||
(def input-example
|
||||
"47|53
|
||||
97|13
|
||||
97|61
|
||||
97|47
|
||||
75|29
|
||||
61|13
|
||||
75|53
|
||||
29|13
|
||||
97|29
|
||||
53|29
|
||||
61|53
|
||||
97|53
|
||||
61|29
|
||||
47|13
|
||||
75|47
|
||||
97|75
|
||||
47|61
|
||||
75|61
|
||||
47|29
|
||||
75|13
|
||||
53|13
|
||||
|
||||
75,47,61,53,29
|
||||
97,61,53,29,13
|
||||
75,29,13
|
||||
75,97,47,61,53
|
||||
61,13,29
|
||||
97,13,75,29,47")
|
||||
|
||||
(def input
|
||||
(string/split input-example #"\n\n"))
|
||||
|
||||
(def page-ordering-rules
|
||||
(reduce
|
||||
(fn [m el]
|
||||
(let [[k v] (map parse-long (string/split el #"\|"))]
|
||||
(if (get m k)
|
||||
(update m k conj v)
|
||||
(assoc m k [v]))))
|
||||
{}
|
||||
(string/split-lines (first input))))
|
||||
|
||||
(def page-updates
|
||||
(let [parse-fn
|
||||
(fn [l]
|
||||
(->>
|
||||
(string/split l #",")
|
||||
(mapv parse-long)))]
|
||||
(->> input second string/split-lines
|
||||
(map parse-fn))))
|
||||
|
||||
(defn safe? [up]
|
||||
)
|
||||
|
||||
(safe? (first page-updates))
|
||||
Loading…
x
Reference in New Issue
Block a user