Problem 56538. Cricket - Report the Result (Part II: Test Matches)
- "Match drawn"
- "TeamName won by n runs"
- "TeamName won by n wickets"
- "TeamName won by an innings and n runs"
- Test matches are played over a fixed time period. If the match is not completed in that time, the result is a draw (regardless of the score).
- To avoid running out of time (thus resulting in a draw), a team can choose to declare their innings completed before they are all out. This is effectively a gamble to forfeit the remainder of their innings for the sake of time.
- After both teams' first innings, if Team B is sufficiently far (200+ runs) behind Team A, A can choose to make B follow-on, meaning Team B has to bat again immediately, while Team A can keep their second innings in reserve if needed. Hence, the order of innings is A, B, B, A (if necessary), instead of the usual A, B, A, B.
- Team A scores 543 and declares with 4 wickets still in hand
- Team B scores 234 (all out)
- Team B, forced to follow-on (309 runs behind), scores 456 and declares with 3 wickets in hand, giving A a target of 148 to win
- Team A scores 123 for the loss of 4 wickets, leaving them 24 runs behind Team B's total
Solution Stats
Problem Comments
-
9 Comments
And thanks for all these problems, they were fun. :)
@Matt it's funny that you say that declarations don't affect the result while follow-ons do --- in my solution, it's just the opposite, I take declarations into account but found that I could ignore follow-ons.
Also, I agree with @Rafael: these problems were fun indeed. Well done, and thanks for the entire set. :)
"The test cases are all real matches, so they are correct", I said overconfidently, overlooking my ability to make stupid copy-paste errors! :)
Thanks again, Rafael for helping find that bug in the tests. You're right that #11 is incorrect - I left off the "(f/o)" on England's second innings. Without it, the score doesn't make any sense because England had more runs, but are all out in what would be the 4th innings, which is impossible. I'll update the test but won't rescore the solutions, so your answers will stand as correct (I don't want to risk breaking your hard work for my mistake).
Your interpretation of test #2 is correct. India batted once. Australia is behind on runs but their second innings is still in progress, so it's a draw.
@Christian: you're right that if you assume the scores have been recorded correctly, you don't need to look for the follow-ons for the MATLAB to work correctly. If you're looking to figure out if an innings is completed, then the "d" after the "/w" is important - I'm guessing that's what you used it for. But you can also shortcut that. When I said declarations don't affect the result, I meant the way the result is reported ("n wickets" or "n runs") - in the table, "___" could mean 123 or 123/4d.
Glad you enjoyed the problems, despite not understanding the subject matter! Maybe that was part of the challenge?
Solution Comments
Show commentsProblem Recent Solvers10
Suggested Problems
-
13567 Solvers
-
5970 Solvers
-
4684 Solvers
-
507 Solvers
-
Electrical Diode Current Calculation
753 Solvers
More from this Author22
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!