Question

In: Statistics and Probability

JAVA JAVA JAVA JAVA JAVA JAVA Cricket County Selections (100 Marks) A local cricket county invited...

JAVA JAVA JAVA JAVA JAVA JAVA

Cricket County Selections

A local cricket county invited players from two neighbouring towns Norwich, Ipswich to form a cricket team of 11 players to participate in an upcoming cricket tournament. After selection process, it has shortlisted 22 players from both towns together and tagged each player skill points between 5 to 10 (both numbers included, only whole numbers are considered) based on their performance. The county has also categorised players into pool of batsmen, bowlers, wicket keepers and all-rounders. A player can only belong to one pool. Now the county has asked its final selection committee to pick 11 players from all shortlisted players following the below rules:

A minimum of 3 and a maximum of 6 batsmen must be selected.

  • A minimum of 3 and a maximum of 6 bowlers must be selected.
  • A minimum of 1 and a maximum of 4 Wicket Keeper must be selected.
  • A minimum of 1 and a maximum of 4 All-rounders must be selected.
  • A maximum of 7 players can be selected from each town.
  • Skill points of selected players combined must not exceed 100 points.

Can you help the selection committee to understand in how many ways they can pick final 11?

Input Format

There will be 22 lines of input.

Each line of the input consists of skill of player, skill points of player and town of player space separately.

Constraints

5<= Skill Points <=10

Output Format

Print the total number of unique 11 member teams that can be formed with all the criteria mentioned in a separate line.

Sample TestCase 1

Input

Batsman 10 Ipswich
Batsman 10 Ipswich
Batsman 10 Ipswich
Batsman 10 Ipswich
Batsman 10 Ipswich
Batsman 10 Ipswich
Batsman 10 Ipswich
Batsman 10 Ipswich
Batsman 10 Ipswich
Batsman 10 Ipswich
Batsman 10 Ipswich
Bowler 10 Suffolk
Bowler 5 Suffolk
Bowler 5 Suffolk
WicketKeeper 10 Suffolk
AllRounder 10 Suffolk
Bowler 10 Suffolk
Bowler 10 Suffolk
Bowler 10 Suffolk
Bowler 10 Suffolk
Bowler 10 Suffolk
Bowler 10 Suffolk

Output

24486

Solutions

Expert Solution

Java code:-

import java.util.*;
public class CandidateCode
{
public static int recurse(int idx, int batsman, int bowler, int wk, int ar, int towner, int sum,int trade[],int skiint[],int town[],int dp[][][][][][][])
{

if(batsman > 6 || bowler > 6 || wk > 4 || sum > 100 || towner > 7 || ar > 4)
{
return 0;
}
int tot = batsman + bowler + wk + ar;
if(idx == 22)
{
if(tot != 11)
{
return 0;
}
if(batsman > 2 && bowler > 2 && wk > 0 && ar > 0 && towner >= 4)
{
return 1;
}
return 0;
}
int x1=idx,x2=batsman,x3=bowler,x4=wk,x5=ar,x6=towner,x7=sum;
int ans = dp[idx][batsman][bowler][wk][ar][towner][sum];
if(ans != -1)
{
dp[x1][x2][x3][x4][x5][x6][x7]=ans;
return ans;
}
ans = 0;
dp[x1][x2][x3][x4][x5][x6][x7]=ans;
int variable_y=recurse(idx+1, batsman, bowler, wk, ar, towner, sum,trade,skiint,town,dp);
ans+= variable_y;
dp[x1][x2][x3][x4][x5][x6][x7]=ans;
if(trade[idx] == 0) batsman++;
if(trade[idx] == 1) bowler++;
if(trade[idx] == 2) wk++;
if(trade[idx] == 3) ar++;
sum+= skiint[idx];
if(town[idx]!=0) towner++;
dp[x1][x2][x3][x4][x5][x6][x7]=ans;
int variable_x=recurse(idx+1, batsman, bowler, wk, ar, towner, sum,trade,skiint,town,dp);
ans+= variable_x;
dp[x1][x2][x3][x4][x5][x6][x7]=ans;
return ans;
}
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int trade[]=new int[22];
int skiint[]=new int[22];
int town[]=new int[22];
for(int i = 0; i < 22; i++) {
String a;
a=sc.next();
if(a.equals("Batsman"))
{
trade[i] = 0;
}
else if(a.equals("Bowler"))
{
trade[i] = 1;
}
else if(a.equals("WicketKeeper"))
{
trade[i] = 2;
}
else
{
trade[i] = 3;
}
skiint[i]=sc.nextInt();
String homeg;
homeg=sc.nextLine();
if(homeg.equals(" Ipswich"))
{
town[i] = 1;
}
else
{
town[i] = 0;
}
}
int dp[][][][][][][]=new int[22][7][7][5][5][8][101];
int x=-1;
for (int i = 0; i < 22; i++){
for (int j = 0; j < 7; j++) {
for (int k = 0; k < 7; k++) {
for (int l = 0; l < 5; l++) {
for (int m = 0; m < 5; m++) {
for (int n = 0; n < 8; n++) {
for (int o = 0; o < 101; o++) {
dp[i][j][k][l][m][n][o]=x;
}}}}}}}
int ans = recurse(0, 0, 0, 0, 0, 0, 0,trade,skiint,town,dp);
System.out.println(ans);
}
}


Related Solutions

JAVA Cricket County Selections (100 Marks) A local cricket county invited players from two neighbouring towns...
JAVA Cricket County Selections A local cricket county invited players from two neighbouring towns Norwich, Ipswich to form a cricket team of 11 players to participate in an upcoming cricket tournament. After selection process, it has shortlisted 22 players from both towns together and tagged each player skill points between 5 to 10 (both numbers included, only whole numbers are considered) based on their performance. The county has also categorised players into pool of batsmen, bowlers, wicket keepers and all-rounders....
Chapter 3 Java Selections M6 A3 (Inside The Triangle) Suppose a right triangle is placed in...
Chapter 3 Java Selections M6 A3 (Inside The Triangle) Suppose a right triangle is placed in a plane as shown in the book. The right-angle point is placed at (0, 0), and the other two points (x,y) are placed at (200, 0), and (0, 100). Write a program that prompts the user to enter a point with x- and y-coordinates and determines whether the point is inside the triangle. *** Methods are not allowed for this assignment. Do each calculation...
// A local community center is holding a fund raising 5k fun run and has invited...
// A local community center is holding a fund raising 5k fun run and has invited 50 small businesses to make a small donation on their behalf for some much needed updates to their facilities. Each business has assigned a representative to attend the event along with a small donation. // Scroll to the bottom of the list to use some advanced array methods to help the event director gather some information from the businesses. const runners = [ {...
ABC is a local Perth based company. It manufactures cricket bats, balls and other accessories. It...
ABC is a local Perth based company. It manufactures cricket bats, balls and other accessories. It has experienced sales growth over the last 7 years. The company has implemented several automated systems in its assembly plan and employs a sales, technical specialist, cost, production and engineering managers. ABC has supply chain relationship with several local, interstate, and international companies for manufacturing bats, balls, and accessories. During early 2020 ABC experienced a major dislocation of its operation due to Covid-19 pandemics...
Question 2(12 Marks) There are 6 cities in Kilroy County.  The county must determine where to build...
Question 2 There are 6 cities in Kilroy County.  The county must determine where to build central fire stations.  The county wants to build the minimum number of central fire stations needed to ensure that at least two fire stations are within 20 minutes (driving time) of each city. The times (in minutes) required to drive between the cities in Kilroy County are given in the table. Formulate a model that will tell Kilroy how many fire stations should be built and...
QDM Question 2 (12 Marks) There are 6 cities in Kilroy County.  The county must determine where...
QDM Question 2 There are 6 cities in Kilroy County.  The county must determine where to build central fire stations.  The county wants to build the minimum number of central fire stations needed to ensure that at least two fire stations are within 20 minutes (driving time) of each city.  The times (in minutes) required to drive between the cities in Kilroy County are given in the table. Formulate a model that will tell Kilroy how many fire stations should be built and...
Abdullah is a batsman who has played 10 matches in a local cricket club. Take user...
Abdullah is a batsman who has played 10 matches in a local cricket club. Take user input in a 2D array to store his score in first row and second row for balls he has faced in each match. Calculate and display the strike rate (SR) of Mr. Abdullah in all 10 matches he has played. SR=score/number of balls faced×100 Count and display the number of 50s and 100s he has score.
In a recent survey of county high school students, 100 males and 100 females, 66 of...
In a recent survey of county high school students, 100 males and 100 females, 66 of the male students and 47 of the female students sampled admitted that they consumed alcohol on a regular basis. Find a 90% confidence interval for the difference between the proportion of male and female students that consume alcohol on a regular basis. Can you draw any conclusions from the confidence interval? For the test of significance questions, clearly indicate each of the formal steps...
A Campaign manager for a local politician is interested in the percentage of Leon County residents...
A Campaign manager for a local politician is interested in the percentage of Leon County residents who intend to vote in the 2020 elections in November. Residents from each neighborhood in Leon County are randomly sample techniques, larger neighborhoods have a larger number of residents randomly sampled and smaller neighborhoods have a smaller number of residents randomly sampled to get a representative sample. Altogether 434 Leon County Residents are sampled. The result is that 39% of the sampled Leon County...
Manage risk A8.2 Why should employees be invited to participate in risk management consultations? (100 words)...
Manage risk A8.2 Why should employees be invited to participate in risk management consultations? (100 words) Answer in your own words.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT