Last active
August 29, 2015 14:07
-
-
Save tahmidsadik/49fadc74d8d2e09e09fb to your computer and use it in GitHub Desktop.
Extracts number from string and adds them up.
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
(use '[clojure.string :only (split)]) | |
(def s "96h11k4959q615948s50922o38h1453ij38w73413d5577lzrqw3780b389750vf100zd29z73j5wh73l6965n85vm77cw10awrjr29265289222238n10013uk10062f9449acbhfgcm35j78q80") | |
(defn num-parser [ls] | |
(split ls #"")) | |
(defn num? [x] | |
(if (= x "") false (number? (read-string x)))) | |
(reduce +(map #(Integer/parseInt %)(filter num? (num-parser s)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment