-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path117.For Science!.clj
More file actions
27 lines (27 loc) · 1.09 KB
/
117.For Science!.clj
File metadata and controls
27 lines (27 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(defn for-science
[ipt]
(let [format (fn [args]
(->> args
(map-indexed (fn [idx e]
(map-indexed
(fn [idx2 e2] {[idx idx2] (str e2)})
e)))
(flatten)
(into {})))
go-f (fn [ipt v]
(let [idx (format ipt)]
(->> v
(map (fn [[l r]] (->> #{[(dec l) r]
[(inc l) r]
[l (inc r)]
[l (dec r)]}
(remove #(nil? (idx %)))
(remove #(#{"#"} (idx %))))))
(apply concat v)
(set))))
m-idx ((clojure.set/map-invert (format ipt)) "M")
c-idx ((clojure.set/map-invert (format ipt)) "C")]
(if ((last (take 20 (iterate (partial go-f ipt) #{m-idx})))
c-idx)
true
false)))