Suppose, you have a run-predictor for cricket matches and the predictor can predict the target run for batting innings.
Posted: Fri Jul 01, 2022 5:34 am
Suppose, you have a run-predictor for cricket matches and thepredictor can predict the target run for batting innings. Now youneed to find out the match-winning combination of batsmen for yourfavorite team given the average runs of different batsmen. You needto find out a combination of batsmen where the total of averageruns equals exactly the runs predicted as the target score by thepredictor.
The input contains the number of batsmen available, the targetrun predicted by the predictor, and the names and average runs ofthe respective batsman.
Assume, the predictor predicted 300 runs as the target and thereare 7 batsmen in your favorite team with their correspondingaverage scores, you need to find out the binary combination (1denoting batsman selected, 0 denotes batsman not selected) of those7 batsmen in order to find the winning combination.
Your task is to use a genetic algorithm to solve this Run-Chaseproblem.
Task Breakdown:
Input:
The first line has a number N and T denoting the number ofbatsmen available and target score respectively followed by N lineseach starting with the batsman's name and a number R denoting theaverage run of the batsman. Here:
N (1 ≤ N ≤ 18)
T (1 ≤ T ≤ 1000)
R (1 ≤ R ≤ 401)
Output:
The output contains a list of all the players and the followingrow contains a binary string denoting 1 for the selected batsmenand 0 for the not selected batsmen where average runs of selectedbatsmen sums up equal to the target or -1 if such a string cannotbe formed.
Examples:
Sample Input 1
8 330
Tamim 68
Shoumyo 25
Shakib 70
Afif 53
Mushfiq 71
Liton 55
Mahmudullah 66
Shanto 29
Sample Output 1
['Tamim', 'Shoumyo', 'Shakib', 'Afif', 'Mushfiq', 'Liton','Mahmudullah', 'Shanto']
10101110
Explanation: Here, the sum of the average runs of Tamim, Shakib,Mushfiq, Liton and Mahmudullah adds up to 68+70+71+55+66 = 330.
The input contains the number of batsmen available, the targetrun predicted by the predictor, and the names and average runs ofthe respective batsman.
Assume, the predictor predicted 300 runs as the target and thereare 7 batsmen in your favorite team with their correspondingaverage scores, you need to find out the binary combination (1denoting batsman selected, 0 denotes batsman not selected) of those7 batsmen in order to find the winning combination.
Your task is to use a genetic algorithm to solve this Run-Chaseproblem.
Task Breakdown:
Input:
The first line has a number N and T denoting the number ofbatsmen available and target score respectively followed by N lineseach starting with the batsman's name and a number R denoting theaverage run of the batsman. Here:
N (1 ≤ N ≤ 18)
T (1 ≤ T ≤ 1000)
R (1 ≤ R ≤ 401)
Output:
The output contains a list of all the players and the followingrow contains a binary string denoting 1 for the selected batsmenand 0 for the not selected batsmen where average runs of selectedbatsmen sums up equal to the target or -1 if such a string cannotbe formed.
Examples:
Sample Input 1
8 330
Tamim 68
Shoumyo 25
Shakib 70
Afif 53
Mushfiq 71
Liton 55
Mahmudullah 66
Shanto 29
Sample Output 1
['Tamim', 'Shoumyo', 'Shakib', 'Afif', 'Mushfiq', 'Liton','Mahmudullah', 'Shanto']
10101110
Explanation: Here, the sum of the average runs of Tamim, Shakib,Mushfiq, Liton and Mahmudullah adds up to 68+70+71+55+66 = 330.