Problem 56523. Cricket - Sort Batters by Distance Run
Given a string vector of batters' names, a vector of the total number of runs they scored, a vector of the number of 4s they scored, and a vector of the number of 6s, return a string array of the player's names sorted according to how far they actually ran for their runs, from farthest to least. You can assume that 4s and 6s were not run at all (so the problem is equivalent to sorting according to the number of runs scored not from boundaries).
For example,
name = ["Matt";"Ben";"Renee"];
runs = [6;18;20];
fours = [0;2;3];
sixes = [0;0;1];
sortednames = sortbyrundistance(name,runs,fours,sixes)
sortednames =
3×1 string array
"Ben"
"Matt"
"Renee"
Here, Matt has run 6 runs, Ben 10 (8 of his total 18 came from 4s), Renee 2 (18 of her 20 runs came from boundaries).
A batter's score is the total of runs physically run and runs scored from boundaries (hitting the ball to the boundary scores an automatic 4 runs, hitting it over the boundary scores an automatic 6 runs). The score is typically reported as the total runs scored, along with the number of boundary 4s and 6s. In the above example, Ben's score is 18 runs (total), including 2 4s and 0 6s. Hence, his score was 10 runs he actually ran, plus 8 runs from boundaries.
Solution Stats
Problem Comments
-
3 Comments
John Mayer
on 14 Nov 2023
ss
FirstATK Last
on 14 Nov 2023
fun problem
LUIS ALBERTO
on 18 Mar 2024
F[Regresion de datos] = O(•) = Funcion de Activacion = Orden de magnitud
Solution Comments
Show commentsProblem Recent Solvers76
Suggested Problems
-
684 Solvers
-
Calculate compression ratio of engine
172 Solvers
-
Calculate the Number of Sign Changes in a Row Vector (No Element Is Zero)
718 Solvers
-
317 Solvers
-
998 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!