Competitive ProgrammingEasy

Count ways to reach score

Detailed guide and Python implementation for the 'Count ways to reach score' problem.

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?
Consider using Dynamic Programming-specific data structures like sets or heaps.
Edge Cases to Watch
  • Empty input structures
  • Single element inputs
  • Large numerical bounds

Ready to Solve?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

Open in Editor

Recommended Python Resources

Expand your knowledge with related interactive tutorials, cheat sheets, and code comparisons.