# 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)
For example:
s = ["53";"163*";"6";"186";"147*";"0";"89*";"0*"];
stats = battingstats(s)
stats =
161 2 3 1
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).

### Solution Stats

36.45% Correct | 63.55% Incorrect
Last Solution submitted on Aug 22, 2024

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!