Problem 58847. Possible American Football Scoring Combinations
With inspiration from Problem 56195. Possible Ruby Scores, given the final score for two teams in an American football game (score1, score2), return two matrices (team1_combs, team2_combs) representing all possible combinations of scores by each team (Official NFL Scoring Plays).
In American football, the 7 possible ways of scoring are:
- Touchdown - 6 points
- Try after touchdown - 1 point
- Try after touchdown - 2 points
- Safety - 2 points
- Field Goal - 3 points
- Defensive safety on try after touchdown (i.e. conversion safety) - 1 points
- Defensive "touchdown" on try after touchdown - 2 points
Values for score1 and score2 include all natural numbers (realistically <100), and the resulting matrices will have dimensions n1 x 7 and n2 x 7, where n1, n2 are the total number of possible scoring combinations for each team, respectively. The order of the elements in the rows for team1_combs and team2_combs should follow the above list.
*** Attention - There is added complexity in the scoring possibilities in that the number of tries after touchdowns (also known as extra points or point after attempts) must be less than or equal to number of touchdowns. This constraint is further complicated by the possibility of defensive scores on tries after touchdowns, in which the possible number of scores is constrained by the touchdowns scored by the opposing team.
This system is known as a linear Diophantine equation, an equation where only the integer--and in this case only nonnegative--solutions are of interest.
Each team's score can be modeled by the following equation:
6(tds) + 1(off. 1 pt. pats) + 2off. 2 pt. pats + 2(safs) + 3(fgs) + 1(def. 1 pt. pats) + 2(def. 2 pt. pats) = score
>>> with the added constraints:
off. 1 pt. pats + off. 2 pt. pats <= tds
def. 1pt. pats + def. 2pt. pats <= tds for opponent
Solution CommentsShow comments
Problem Recent Solvers5