Created
June 25, 2020 15:22
-
-
Save SVMBrown/8171e28303cbb00cb9a4edf9625a6414 to your computer and use it in GitHub Desktop.
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 frame-size [[a :as rolls]] | |
(if (= 10 a) | |
1 | |
2)) | |
(defn frame-score [[a b c :as rolls]] | |
(if (>= 10 (+ a b)) | |
(+ a b c) | |
(+ a b))) | |
(defn total-score [rolls] | |
(loop [frames 10 | |
score 0 | |
rolls rolls] | |
(if (= 0 frames) | |
score | |
(recur (dec frames) | |
(+ score (frame-score rolls)) | |
(drop (frame-size rolls) rolls))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment