Skip to content

Instantly share code, notes, and snippets.

Created May 28, 2011 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/997316 to your computer and use it in GitHub Desktop.
Save anonymous/997316 to your computer and use it in GitHub Desktop.
;; jneira's solution to Graph Connectivity
;; https://4clojure.com/problem/91
(fn ? [c]
(let [[x & s] (map set c)
p (group-by #(if (some x %) 1 0) s)
y (set (apply concat x (p 1)))]
(or (nil? (p 0))
(and (not= x y)
(? (cons y (p 0)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment