DEV Community

Discussion on: Daily Challenge #251 - Largest Number in a Sequence

Collapse
 
quoll profile image
Paula Gearon
(defn digit5 [n] (apply max (sequence (comp (map (partial apply str)) (map #(Long/parseLong %))) (partition 5 1 (str n)))))
Collapse
 
quoll profile image
Paula Gearon

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)))