Skip to content

Instantly share code, notes, and snippets.

@Anderssorby
Created July 7, 2016 14:10
Show Gist options
  • Save Anderssorby/a9c040683d020d0f48d0a71d2a9e19fd to your computer and use it in GitHub Desktop.
Save Anderssorby/a9c040683d020d0f48d0a71d2a9e19fd to your computer and use it in GitHub Desktop.
;; 4clojure problem #53
(fn [s] (loop [longest [] r (sorted-set) [x n & xs :as l] s]
(cond
(nil? n) longest
(= n (inc x)) (recur (if (> (+ 2 (count r)) (count longest)) (vec (conj r x n)) longest) (conj r x n) (rest l))
:else (recur longest (sorted-set) (rest l)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment