|
|
@ -1,12 +1,11 @@
|
|
|
|
|
|
|
|
(require '[clojure.string :as str])
|
|
|
|
|
|
|
|
|
|
|
|
(def bitcount 12)
|
|
|
|
(def bitcount 12)
|
|
|
|
(def input
|
|
|
|
(def input
|
|
|
|
(loop [tot []]
|
|
|
|
(->> "./in"
|
|
|
|
(let [line (read-line)]
|
|
|
|
(slurp)
|
|
|
|
(if (empty? line)
|
|
|
|
(str/split-lines)
|
|
|
|
tot
|
|
|
|
(map #(Integer/parseInt % 2))
|
|
|
|
(recur (conj tot (Integer/parseInt line 2)))
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -16,27 +15,17 @@
|
|
|
|
(apply +)
|
|
|
|
(apply +)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
(defn filterbit [lst bit v]
|
|
|
|
(defn filterbit [lst bit v]
|
|
|
|
(if (= 1 (count lst))
|
|
|
|
(if (= 1 (count lst))
|
|
|
|
lst
|
|
|
|
lst
|
|
|
|
(loop [l lst r []]
|
|
|
|
(filter #(= (bit-test % bit) v) lst)
|
|
|
|
(if (empty? l)
|
|
|
|
|
|
|
|
r
|
|
|
|
|
|
|
|
(recur
|
|
|
|
|
|
|
|
(rest l)
|
|
|
|
|
|
|
|
(if (= (bit-test (first l) bit) v)
|
|
|
|
|
|
|
|
(conj r (first l))
|
|
|
|
|
|
|
|
r
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
(loop [bit (dec bitcount) lst0 input lst1 input]
|
|
|
|
(loop [bit (dec bitcount) lst0 input lst1 input]
|
|
|
|
(if (and (= 1 (count lst0)) (= 1 (count lst1)))
|
|
|
|
(if (and (= 1 (count lst0)) (= 1 (count lst1)))
|
|
|
|
(println (* (first lst0) (first lst1)))
|
|
|
|
(println (map * lst0 lst1))
|
|
|
|
(recur
|
|
|
|
(recur
|
|
|
|
(dec bit)
|
|
|
|
(dec bit)
|
|
|
|
(filterbit lst0 bit (>= (countbit lst0 bit) (/ (count lst0) 2)))
|
|
|
|
(filterbit lst0 bit (>= (countbit lst0 bit) (/ (count lst0) 2)))
|
|
|
|