Problem 56498. Cricket - Career Batting Statistics
Given a vector s of strings representing a batter's individual innings scores, return their career statistics as a 4-element (numeric) row vector representing: average, half-centuries, centuries, and ducks. The strings will be in the form of a number ("42") or a number with an asterisk ("42*") to represent "not-out".
- Batting average is defined as total runs divided by number of dismissals (ie number of innings - number of not-outs).
- Half-centuries is the number of scores from 50 to 99 (whether out or not-out)
- Centuries is the number of scores greater than 99 (whether out or not-out)
- Ducks is the number of scores of 0 out (0* should not be counted)
In this case, the batter has a total of sum([53 163 6 186 147 0 89 0]) = 644 runs from 4 completed innings (8 innings - 4 not-outs). Hence their average is 644/4 = 161. They have two half-centuries (53 and 89*), three centuries (163*, 186, 147*), and one duck (0 - the 0* does not count as a duck).