(defn digit5 [n] (apply max (sequence (comp (map (partial apply str)) (map #(Long/parseLong %))) (partition 5 1 (str n)))))
To be honest, the solutions I provide here would NEVER pass code review. But I get it working at a REPL, and it's just too tempting to post as-is 😊
Here is a nearly identical solution (sans the transducer), written in a readable way:
(defn digit5 [n] (->> (str n) (partition 5 1) (map (partial apply str)) (map #(Long/parseLong %)) (apply max)))
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
To be honest, the solutions I provide here would NEVER pass code review. But I get it working at a REPL, and it's just too tempting to post as-is 😊
Here is a nearly identical solution (sans the transducer), written in a readable way: