   [comp-f]
   (let [input (day-input-line-seq 9)
         distances (into {} (map #(let [[[_ from to dist]] (re-seq #"^(\w+) to (\w+) = (\d+)$" %)]
-                          [#{from to} (s->int dist)]) input))
+                                  [#{from to} (s->int dist)]) input))
         places (reduce #(let [[endpoints _] %2]
                          (conj % (first endpoints) (last endpoints))) #{} distances)
         all-routes (permutations places)


;day 11
;just building blocks
;string into number
(defn- no-iol? [ch-seq]
  (not-any? #(#{105 108 111} %) ch-seq))

(defn- s->big-int
  "Simply transforms string into big integer consisting of concatenated character codes"
  [s]
  (BigInteger. (clojure.string/join (map #(format "%03d" %) (map int s)))))

(defn- big-int->ch-seq
  "Simply transforms big-int into sequence of 3 digit numbers"
  [num]
  (map #(s->int (apply str %)) (partition 3 (str num))))

(defn- ch-seq->str
  "Char sequence (ch here is 8bit int actually)"

(defn- has-distinct-pairs?
  "Determines if sequence contains two distinct pairs (pairs consist of different chars)"
  [xs]
  (let [[one two] (take 2 (filter
                            #(= 2 (count %))
                            (partition-by identity xs)))]
    (and one two (not= (first one) (first two)))))

(defn- has-inc-of-three?
  "Determines if provided input sequence containes increasing straight of at least three letters"
  [xs]
  (= 3 (count
         (reduce #(if (= (dec %2) (last %))
                   (let [med (conj % %2)]
                     (if (= 3 (count med))
                       (reduced med)
                       med))
                   [%2]) [(first xs)] (rest xs)))))

;naive inefficient attempt
;(defn day11 [input]
;  (let [a0 (first (s->ch-seq input))]
;    (for [a (range (int a0) 123)
;          b (range 97 123)
;          c (range 97 123)
;          d (range 97 123)
;          e (range 97 123)
;          f (range 97 123)
;          g (range 97 123)
;          h (range 97 123)
;          :let [cs [a b c d e f g h]]
;          :when (and (no-iol? cs)
;                     (has-inc-of-three? cs)
;                     (has-distinct-pairs? cs)
;                     (pos? (compare (ch-seq->str cs) input)))]
;      cs)))

;quite enough efficient solution
(defn day11 [input]
  (reduce #(if (and
                 (has-inc-of-three? %2)
                 (no-iol? %2)
                 (has-distinct-pairs? %2))
            (reduced (ch-seq->str %2)))
          (iterate (fn [x]
                     (if (= 122 (last x))
                       (let [cnt (count (take-while #(= % 122) (reverse x)))]
                         (vec (map-indexed #(let [pos (- 7 cnt)]
                                             (cond
                                               (= pos %) (inc %2)
                                               (< % pos) %2
                                               (> % pos) 97))
                                           x)))
                       (assoc x 7 (inc (last x))))) (s->ch-seq input))))


