Given a natural number s (> 4), representing a rugby team's score, return an n-by-3 matrix representing all n possible combinations of tries, conversions, and penalties (or drop goals) that would result in such a score. The first column of the matrix represents the number of tries, the second column the number of conversions, the third column the number of penalties or drop goals. The order of the rows is not important, as long as all possibilities are uniquely represented.
In rugby, a try scores 5 points, a conversion scores 2, and a penalty or drop goal scores 3. However, a conversion can only be attempted after scoring a try. Hence the number of conversions can never be more than the number of tries.
tcp = scorebreakdown(12)
tcp =
2 1 0
0 0 4
Two tries = 2*5 = 10 points. One conversion = 2 points. Total = 10 + 2 = 12.
Four penalties = 4*3 = 12 points.
Note that 1 try, 2 conversions, and 1 penalty would total 12 points, but is not allowed because it is not possible to have more conversions than tries.
(This problem can be treated as finding all integer linear combinations of 5, 2, and 3, such that 5a + 2b + 3c = s, but with a restriction: b <= a.)
Solution Stats
Problem Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers119
Suggested Problems
-
Find the longest sequence of 1's in a binary sequence.
6843 Solvers
-
Change the sign of even index entries of the reversed vector
661 Solvers
-
Given a square and a circle, please decide whether the square covers more area.
1895 Solvers
-
268 Solvers
-
216 Solvers
More from this Author35
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!