Back to Practice Dashboard
Competitive ProgrammingEasy
Count ways to reach score
Learn how to solve the 'Count ways to reach score' problem. This detailed resource details brute force and optimized approaches.
Problem Statement
Easy
Write a function count_ways_score(n) that returns the number of distinct combinations of moves to reach a score n in a game where a player can score 3, 5, or 10 points in each move. Note that combinations with different ordering of moves are considered the same (e.g., scoring 3 then 5 is the same combination as scoring 5 then 3).
Constraints
- •1 <= n <= 1000
Examples
Example 1
Input
count_ways_score(13)
Output
2
Explanation
There are 2 combinations to reach 13: {3, 5, 5} and {3, 10}.
Example 2
Input
count_ways_score(20)
Output
4
Explanation
There are 4 combinations to reach 20: {10, 10}, {5, 5, 10}, {5, 5, 5, 5}, and {3, 3, 3, 3, 3, 5}.
Need a Hint?
Define subproblem states, establish the recurrence relation, and use memoization (top-down) or tabulation (bottom-up).
Edge Cases to Watch
- Empty list or null input variables
- Single item lists/arrays
- Extremely large input bounds causing integer or stack overflow
Ready to Solve?
Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.