Skip to content

Instantly share code, notes, and snippets.

@tnunamak
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tnunamak/76462c0015a100fafc9c to your computer and use it in GitHub Desktop.
Save tnunamak/76462c0015a100fafc9c to your computer and use it in GitHub Desktop.
Problem Four - Programming problems software engineers should be able to solve
;; 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