Sha256: f4636609930fe5442ff9f82d1d500dc90c45399ff341cee7b89b78fe401712f4
Contents?: true
Size: 920 Bytes
Versions: 12
Compression:
Stored size: 920 Bytes
Contents
module Bowling let numberOfFrames = 10 let maximumFrameScore = 10 let roll pins game = game @ [pins] let score game = let roll index = List.item index game let isStrike frameIndex = roll frameIndex = maximumFrameScore let isSpare frameIndex = roll frameIndex + roll (frameIndex + 1) = maximumFrameScore let strikeBonus frameIndex = roll (frameIndex + 1) + roll (frameIndex + 2) let spareBonus frameIndex = roll (frameIndex + 2) let sumOfBallsInFrame frameIndex = roll frameIndex + roll (frameIndex + 1) let folder (score, frameIndex) _ = if isStrike frameIndex then (score + 10 + strikeBonus frameIndex, frameIndex + 1) elif isSpare frameIndex then (score + 10 + spareBonus frameIndex, frameIndex + 2) else (score + sumOfBallsInFrame frameIndex, frameIndex + 2) [1..numberOfFrames] |> List.fold folder (0, 0) |> fst let newGame = []
Version data entries
12 entries across 12 versions & 1 rubygems