Skip to content

Instantly share code, notes, and snippets.

@iamdustan
Created September 2, 2014 02:06
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 iamdustan/83d8f3c8759e31eb0f74 to your computer and use it in GitHub Desktop.
Save iamdustan/83d8f3c8759e31eb0f74 to your computer and use it in GitHub Desktop.
codeeval simple-sorting
(ns worky
(:gen-class)
(:use clojure.pprint))
(defn process [line]
(if (not= "" line)
(sort (vec (map read-string (re-seq #"-?[\d.]+" line))))))
(defn fmt [line]
(clojure.string/join
" "
(map (fn [n] (format "%.3f" n))
line)))
(defn -main [args]
(with-open [rdr (clojure.java.io/reader args)]
(doseq [line (line-seq rdr)]
(println (fmt (process line))))))
(apply -main *command-line-args*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment