Created
July 25, 2016 17:38
-
-
Save tiagodavi/1747bd83b144a1aecd32bb14800b2750 to your computer and use it in GitHub Desktop.
Compare the Triplets.clj
This file contains hidden or 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
(defn to-int [x] | |
(Integer/parseInt x)) | |
(defn string-to-vector [x] | |
(clojure.string/split x #" ")) | |
(def alice-points (atom 0)) | |
(def bob-points (atom 0)) | |
(defn counter [points] | |
(swap! points inc)) | |
(defn calculate [a b] | |
(let [x (to-int a) | |
y (to-int b)] | |
(cond | |
(> x y) (counter alice-points) | |
(> y x) (counter bob-points) | |
:else :nobody | |
)) {:alice @alice-points :bob @bob-points}) | |
(def alice (string-to-vector (read-line))) | |
(def bob (string-to-vector (read-line))) | |
(def result (last (map calculate alice bob))) | |
(println (result :alice) (result :bob)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment