Suppose you have five six-sided dice, and you roll all of them at the same time. For some games (ncluding yahtzee, as you will see in the next question),we may be interested in the sum of particular values rolled. For example, if we roll (2, 5, 2, 3, 2), we may want to know that the sum of the 2s is 6, that the sum of the 3s is 3, or that the sum of the 4s is 0.
Write the function (sum-matchin d1 d2 d3 d4 d5 match-val) that consumes the values rolled on 5 dice (d1, d2, d3, d4, d5) and the number that we are interested in summing (match-val), and produces the sum of all those dice that match match-val. Note that dice values are not guaranteed to be ordered in any particular way.
Hint: your solution should not attempt to list all of the possible combinations of positions that matching dice could be in. (You will lose marks if you do this) Instead, consider how using a helper fuction could simplify your code to make thetask of summing much simpler.
For example:
> (sum-matching 2 5 2 3 2 2)
6
> (sum-matching 2 5 2 3 2 3)
3
> (sum-matching 2 5 2 3 2 4)
0
Save your code in a file called a02q2. rkt and submit it to MarkUs.