Last active
August 29, 2015 14:20
-
-
Save tnunamak/76462c0015a100fafc9c to your computer and use it in GitHub Desktop.
Problem Four - Programming problems software engineers should be able to solve
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
;; https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour | |
;; problem four, not all that pretty | |
(defn numseq [x] | |
(map (comp read-string str) (str x))) | |
(defn strsort [x | |
y] | |
(let [a (first x) | |
b (first y)] | |
(cond | |
(and (not a) (not b)) 0 | |
(not b) 1 | |
(not a) -1 | |
(> a b) -1 | |
(< a b) 1 | |
:else (strsort (rest x) (rest y))))) | |
(defn biggest [nums] | |
(apply str (map #(apply str %) | |
(sort strsort | |
(map numseq nums))))) | |
(biggest [5 55 50]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment