Created
January 11, 2020 12:34
-
-
Save faust45/6824a3c8e3beda09bd7f0817822b7b58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns app | |
(:require [clojure.string :refer [replace]])) | |
(def s1 "[[][{]]") | |
(def s2 "[[]][][{]}[]") | |
(def s3 "[[{}][]]") | |
(def s4 "([)]") | |
(def pattern #"\[\]|\{\}|\(\)") | |
(defn is-valid? | |
[s] | |
(let [has-patterns (->> s (re-find pattern))] | |
(if has-patterns | |
(-> s (replace pattern "") process) | |
(if (empty? s) | |
[:valid] | |
[:in-valid s])))) | |
(is-valid? s4) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment