Find Combinations for Game Scoring
Find the number of ways a player can score n runs.
We'll cover the following...
We'll cover the following...
Statement
Imagine a game where, in each turn, a player can score either or runs. Given a score, n, find the total number of ways to score n runs.
Examples
To score runs, a player can score in the following three ways:
To score runs, a player can score in the following ten ways:
Sample input
5
Expected output
10
Try it yourself
Solution 1: Recursion
We can only score , , or points in this game. To reach a score of , we can only use increments of , , or . To reach a score of , we can:
- score in the last turn
- score