Last active
June 2, 2018 18:13
-
-
Save msszczep/3d1c1e5fc5f4ccfda6033e04096c3897 to your computer and use it in GitHub Desktop.
WQC Score Calculator
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
| ; #wqc #clojure | |
| ; For the World Quizzing Championships | |
| ; http://www.worldquizzingchampionships.com/ | |
| (def sample-scores | |
| [["joshua Kreitzer" 1 2 3 4 5 6 7 8] | |
| ["Sreeradh RP" 9 10 11 12 13 14 15] | |
| ["david striasny" 3 8 8 7 20 4 14 11]]) | |
| (defn get-wqc-scores [s] | |
| (letfn [(calculate-score [list-of-scores] | |
| (- (reduce + list-of-scores) | |
| (apply min list-of-scores)))] | |
| (->> s | |
| (map (juxt first (comp calculate-score rest))) | |
| (sort-by second) | |
| reverse))) | |
| ; (get-wqc-scores sample-scores) | |
| ; => (["Sreeradh RP" 75] ["david striasny" 72] ["joshua Kreitzer" 35]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment