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
Solution Comments
Show comments
Loading...
Problem Recent Solvers81
Suggested Problems
-
Find the sum of all the numbers of the input vector
54016 Solvers
-
Determine whether a vector is monotonically increasing
22889 Solvers
-
2243 Solvers
-
Sum all integers from 1 to 2^n
17436 Solvers
-
Return the first and last characters of a character array
11829 Solvers
More from this Author33
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
ss
fun problem
F[Regresion de datos] = O(•) = Funcion de Activacion = Orden de magnitud