Skip to content

Instantly share code, notes, and snippets.

@SVMBrown
Created June 25, 2020 15:22
Show Gist options
  • Save SVMBrown/8171e28303cbb00cb9a4edf9625a6414 to your computer and use it in GitHub Desktop.
Save SVMBrown/8171e28303cbb00cb9a4edf9625a6414 to your computer and use it in GitHub Desktop.
(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