Skip to content

Instantly share code, notes, and snippets.

@faust45
Created January 11, 2020 12:36
Show Gist options
  • Save faust45/97d6e43d78e5fde6e8aafdd61357d102 to your computer and use it in GitHub Desktop.
Save faust45/97d6e43d78e5fde6e8aafdd61357d102 to your computer and use it in GitHub Desktop.
(ns app
(:require [clojure.string :refer [replace]]))
(def s1 "[[][{]]")
(def s2 "[[]][][{]}[]")
(def s3 "[[{}][]]")
(def s4 "([)]")
(def pattern #"\[\]|\{\}|\(\)")
(defn is-valid?
[s]
(if (re-find pattern s)
(-> s (replace pattern "") is-valid?)
(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