File tree 1 file changed +13
-0
lines changed
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 33
33
letter-frequency (get frequencies letter)]
34
34
(and (>= letter-frequency min) (<= letter-frequency max))))
35
35
36
+ (defn- validate-password-position
37
+ [condition-password]
38
+ (let [password (:password condition-password)
39
+ min (get-in condition-password [:condition :min ])
40
+ max (get-in condition-password [:condition :max ])
41
+ letter (get-in condition-password [:condition :letter ])
42
+ letter-at-min-match (= letter (nth password (- min 1 )))
43
+ letter-at-max-match (= letter (nth password (- max 1 )))]
44
+ (and (or letter-at-min-match letter-at-max-match) (not (and letter-at-min-match letter-at-max-match)))))
45
+
36
46
(def frequency-validity (map #(validate-password-frequency (parse-line %)) input))
37
47
48
+ (def position-validity (map #(validate-password-position (parse-line %)) input))
49
+
38
50
(count (filter #(identity %) frequency-validity))
51
+ (count (filter #(identity %) position-validity))
You can’t perform that action at this time.
0 commit comments