Problem Statement
In darts, the target is divided into sections. Each section has an assigned point value: a positive integer. These values are as follows:
- For each x between 1 and 20, inclusive, there are sections worth 1*x, 2*x, and 3*x points. (These are called "single x", "double x", and "triple x".)
- In the middle of the target is the bullseye. The bullseye consists of two sections: the outer one is worth 25 points and the inner one is worth 50.
You are given the int N.
Determine whether it's possible to score exactly N points by hitting the target with at most three darts. If no, return an empty int[]. If yes, return a int[] containing one way of scoring N points: for each dart that hits the target the number of points it scores.
Definition
- Class:
- ThreeDarts
- Method:
- throwDarts
- Parameters:
- int
- Returns:
- int[]
- Method signature:
- int[] throwDarts(int N)
- (be sure your method is public)
Constraints
- N will be between 1 and 200, inclusive.
Examples
50
Returns: {50 }The simplest way to score 50 points is to take one dart and hit the inner bullseye.179
Returns: { }There is no way to score exactly 179 points using at most three darts.6
Returns: {3, 1, 2 }If a solution exists, any valid solution will be accepted. It's not required to use the smallest possible number of darts. The returned int[] does not have to be sorted.60
Returns: {30, 30 }Different darts may hit the same section of the target and thus get the same score. (The value 30 can be scored with a single dart by hitting the "double 15" section that is worth 2*15 points.)23
Returns: {1, 22 }No section is worth exactly 23 points so we need to use at least two darts. Our solution throws one dart into the single 1 and then one dart into the double 11.