Program to show individual score and extras from a given cricket score timeline using Python
This Python program takes String input and returns a list called players_score in which individual score of players are stored. Along with the list, another variable is also returned in which extra's are stored.
Input format :
1..2.w.b6W
here
. indicates a dot ball (no runs scored off that ball)
w indicates wide
b indicates byes
W indicates Wicket
this program assumes fresh innings and considers only wide and byes as extra runs
Example :
input 1: 1..2..
first ball p1 (striker's end) scores a single hence strike is rotated and p2 (non-striker's end) comes to the striker's end and no runs scored off next 2 balls, p2 is still at the striker's end and the next ball 2 runs are scored strike remains the same, no runs scored off next 2 balls
hence output will be
[1,2,0,0,0,0,0,0,0,0]
without any extras
input 2: WWWWWWWWWW
this is all-out condition without a run hence output will be
[0,0,0,0,0,0,0,0,0,0]
without any extras
Submitted by Sheshagiri Kulkarni (sheshagiri)
Download packets of source code on Coders Packet
Comments