Created
August 1, 2011 01:34
-
-
Save ibdknox/1117436 to your computer and use it in GitHub Desktop.
problem 53 http://www.4clojure.com/problem/53
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
#(:longest | |
(reduce | |
(fn [{:keys [longest cur] :as res} n] | |
(let [{:keys [cur] :as updated} (if (or (not (seq cur)) | |
(> n (last cur))) | |
(update-in res [:cur] conj n) | |
(assoc res :cur [n])) | |
longest-cnt (count longest) | |
cur-cnt (count cur)] | |
(if (and (> cur-cnt 1) | |
(> cur-cnt longest-cnt)) | |
(assoc updated :longest cur) | |
updated))) | |
{:longest [] :cur []} %)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment