Find Combinations for Game Scoring
Explore techniques to solve dynamic programming problems by finding all the combinations to reach a given game score using scoring increments of 1, 2, or 4 runs. Understand recursive solutions, optimize with memoization, and apply tabulation for efficient computation and reduced complexity.
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