# Problem 56493. Cricket - How Much More to Beat Bradman?

Sir Don Bradman famously needed only 4 runs in his final innings to retire with an average of 100. Out for a duck, he ended instead with the legendary figure of 99.94.
Given a player's career average and total runs scored, calculate how many runs they would need to score in one final innings to bring their career average to 100 (assuming, for safety, that they will be dismissed in this final innings).
Batting average is defined as total runs divided by number of dismissals (ie number of innings - number of not-outs).
For example, Bradman himself scored 6996 runs at an average of 99.94. Given one more innings, he would need to score 104 runs, to get a total of 7100, for an average of 7100/(71 dismissals) = 100. (This makes sense - he still needs the 4 from the previous innings, plus another 100 for the new one.)
Chris Martin, on the other hand, scored 123 runs at an average of 2.36. Given one more innings to get his average to 100, he would need to score a mere 5177 runs.
% The Don
r = beatthedon(99.94,6996)
r =
104
% Chris Martin
r = beatthedon(2.36,123)
r =
5177

### Solution Stats

46.85% Correct | 53.15% Incorrect
Last Solution submitted on May 23, 2024

### Community Treasure Hunt

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

Start Hunting!