diff --git a/src/main/kotlin/rps/Game.kt b/src/main/kotlin/rps/Game.kt index 9fff147..7f4d0a5 100644 --- a/src/main/kotlin/rps/Game.kt +++ b/src/main/kotlin/rps/Game.kt @@ -34,4 +34,9 @@ fun determineOutcome(first: Move, second: Move): Outcome = when { else -> Outcome.LOSS } -fun calculateGameSummary(turns: List): GameSummary = TODO() +// Note: This would be slightly more efficient (but a lot less elegant) with an imperative loop and three mutable integers. +fun calculateGameSummary(turns: List) = GameSummary( + wins = turns.count { it == Outcome.WIN }, + draws = turns.count { it == Outcome.DRAW }, + losses = turns.count { it == Outcome.LOSS }, +)