-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0020-sequence-full-of-colors.clj
37 lines (34 loc) · 1.07 KB
/
0020-sequence-full-of-colors.clj
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
28
29
30
31
32
33
34
35
36
37
(ns sequence-full-of-colors)
;; https://www.hackerrank.com/challenges/sequence-full-of-colors
;; dif: easy
;; init 2023/11. done.
(def input "4
RGGR
RYBG
RYRB
YGYGRBRB")
(with-in-str input
(let [n (read)
_ (read-line)] ; empty space after number :/
(doseq [_ (range n)]
(let [s (read-line)
f (frequencies s)]
(if (every? true?
[(= (f \R) (f \G))
(= (f \Y) (f \B))
(->> (seq s)
(map #(case %
\R 1
\G -1
0))
(reductions +)
(every? #(contains? #{1 0 -1} %)))
(->> (seq s)
(map #(case %
\Y 1
\B -1
0))
(reductions +)
(every? #(contains? #{1 0 -1} %)))])
(println "True")
(println "False"))))))