BPL Mubarak

Bangladesh Premier League is in Sylhet for the first time. Today’s match is Sylhet Sixers vs the Dha…

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

#include<stdio.h>
#include<string.h>
int main()
{
	int t,i,b,c,o;
	scanf("%d",&t);
	char s[100];
	while (t--)
	{
		scanf("%s",s);
		c=0;
		for (i=0;s[i]!='\0';i++)
		{
			if (s[i]=='N' ||s[i]=='W' ||s[i]=='D')
			continue;
			else
			c++;
		}
	if (c<=6)
	{
		if (c==1)
		printf("1 BALL\n");
		else if (c==6)
		printf("1 OVER\n");
		else
		printf("%d BALLS\n",c);
	}
	else if (c>6)
	{
		o=c/6;
		b=c%6;
		if (o>=1&&b>=1)
		{
			if (o==1)
			{
				if (b==1)
				printf("1 OVER 1 BALL\n");
				else
				printf("1 OVER %d BALLS\n",b);
			}
			else
			{
				if (b==1)
				printf("%d OVERS 1 BALL\n",o);
				else
				printf("%d OVERS %d BALLS\n",o,b);
			}
		}
	}
	}
}

What’s the problem? I can’t understand

In line 8, it should be while(t- -)

check the quotation in lines 12, 14, 22, 24, 36, 38.

1 Like

import java.util.*;

public class solution{

public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    //System.out.println("enter no. of test cases: ");
    int n = sc.nextInt();
    int x = 0;
    while(x<=n){            
        int count=0;
        //System.out.println("enter result of the deliveries: ");
        String s = sc.nextLine().toUpperCase();
        //String a = s.toUpperCase();
        int size = s.length();
        for(int i=0; i<size; i++){
            char c = s.charAt(i);
            if(c=='N' || c=='W' || c=='D')
                count = count+0;
            else count+=1;
        }
        
        if(count==1){
            System.out.println(count+" BALL");
        } else if(count>1 && count<6){
            System.out.println(count+" BALLS");
        } else if(count==6){
            System.out.println(count/6+" OVER");
        } else if(count>6 && count%6==0){
            System.out.println(count+" OVERS");
        } 
        else if(count>0) {
            System.out.println(count/6+" OVER "+count%6+" BALL");
        }
        x++;
    }       
}

}

CAN YOU SHOW ME WHERE THE PROBLEM IS!

n=int(input())
set=[]
i=1
while i<=n:
s=str(input())
set.append(s)
i+=1
for x in range(len(set)):
a=str(set[x])
over=[]
for k in range(len(a)):
if (a[k]==‘0’ or a[k]==‘1’ or a[k]==‘2’ or a[k]==‘3’ or a[k]==‘4’ or a[k]==‘5’ or a[k]==‘6’ or a[k]==‘O’):
over.append(a[k])
if len(over)>6:
j=abs(len(over)-6)
if j==1:
print(len(over)//6,‘OVER’,j,‘BALL’)
else:
print(len(over)//6,‘OVER’,j,‘BALLS’)
elif len(over)==6:
print(len(over)//6,‘OVER’)
else:
if (len(over)==1):
print(len(over),‘BALL’)
else:
print(len(over),‘BALLS’)

What is the prblm?

T=int(input())
for i in range(T):
def BPL(S):
T=[“W”,“N”,“D”]
k=0
for i in S:
if i not in T:
k=k+1
O=k//6
B=k%6
if k==1:
print(k,“Ball”)
if k>1 and k<6:
print(k,“Balls”)
if k>5:
if O==1:
if B==0:
print(O,“Over”)
elif B==1:
print(O,“Over”,B,“Ball”)
else:
print(O,“Over”,B,“Balls”)
if O>1:
if B==0:
print(O,“Over”)
elif B==1:
print(O,“Over”,B,“Ball”)
else:
print(O,“Over”,B,“Balls”)
S=input()
BPL(S)

What’s the prblm in it?

len = int(input())
for i in range(len):
b = input()
total_ball = 0
for i in b:
if i != “W” and i != “N” and i != “D”:
total_ball += 1
over = int(total_ball / 6)
balls = total_ball - (6 * over)

if 0 < over < 2:
    print(over, "OVER", end=" ")
elif over > 1:
    print(over, "OVERS", end=" ")
if balls == 1:
    print(balls, "BALL", end=" ")
elif balls > 1:
    print(balls, "BALLS", end=" ")
print(end="\n")

What’s the problem here

BPL Mubarak!#include

#include

using namespace std;

int main() {

int n;
cin>>n;

while(n){
    string str;
    cin>>str;

    int len=str.length(), count=0,i,t,r;

    for(i=0;i<len;i++){
        if(str[i] == 'N' || str[i] == 'W' || str[i] == 'D'){
            count++;
        }
    }
   
    int balls = len-count;
 
    if(balls >= 6)
    {
         t = balls/6;
         r = balls%6;
         if(t>1 && r>1){
            cout<< t << " OVERS " << r << " BALLS"<<endl;
         }
         else if(t>1 && r==1){
            cout<< t << " OVERS " << r << " BALL"<<endl;
         }
         else if(t==1 && r>1){
            cout<< t << " OVER " << r << " BALLS"<<endl;
         }
         else if(t==1 && r==1){
            cout<< t << " OVER " << r << " BALL"<<endl;
         }
         else if(t>1 && r==0){
            cout<< t << " OVERS " <<endl;
         }
         else{
            cout<< t << " OVER " <<endl;
         }
    }else{
        if(balls>1){
            cout<<balls << " BALLS"<<endl;
        }else{
            cout<<balls << " BALL"<<endl;
        }


    }

    n--;
}
return 0;

}

can any one tell me what is the problem in my code?
every time it is showing wrong answer in sample 1.

#include
using namespace std;

bool is(char valids[], char c) {
for (int i = 0; i < 9; i++) {
if (valids[i] == c) {
return true;
}
}
return false;
}

int count(string input) {
char valids[9] = {‘0’, ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘o’, ‘O’};
int c = 0;

for (int i = 0; i < input.length(); i++) {
	if (is(valids, input[i])) {
		c++;
	}
}
return c;

}

int main() {
int t;
cin >> t;
while (t–) {
string input;
cin >> input;

	int total = count(input);
	int overs = total/6;
	int balls = total % 6;
	
	string ov = " OVERS ";
	string ba = " BALLS";
	
	if (overs >= 1) {
	    if (overs == 1) {
		    cout << overs << " OVER ";
	    } else {
	        cout << overs << " OVERS ";
	    }
	}
	if (balls >= 1) {
	    if (balls == 1) {
		    cout << balls << " BALL";
	    } else {
	        cout << balls << " BALLS";
	    }
	}
	cout << endl;
}

}

What is the problem in the above code? It shows wrong answer in sample 1.

You will have to check the blank space properly.

class BPL:
def init(self, charList):
self.charList = charList
totalBalls = 0
for i in range(len(charList)):
if charList[i] == ‘N’:
pass
elif charList[i] == ‘W’:
pass
elif charList[i] == ‘D’:
pass
elif charList[i] == ‘O’:
totalBalls = totalBalls + 1
elif int(charList[i]) >= 0 and int(charList[i]) <= 6:
totalBalls = totalBalls + 1
if totalBalls < 6:
print(totalBalls, “Balls”)
elif totalBalls >= 6 and totalBalls % 6 == 0:
o = totalBalls // 6
if o == 1:
print(str(o) + " Over")
else:
print(str(o) + " Overs")
elif totalBalls >= 6 and totalBalls % 6 == 1:
o = totalBalls // 6
v = str(totalBalls % 6)
if o == 1:
print(f"{o}" + " Over " + v + " Ball")
else:
print(f"{o}" + " Overs " + v + " Ball")
elif totalBalls >= 6 and totalBalls % 6 != 0:
o = totalBalls // 6
v = str(totalBalls % 6)
if o == 1:
print(f"{o}" + " Over " + v + " Balls")
else:
print(f"{o}" + " Overs " + v + " Balls")

n = int(input())
i = 1
while i < n + 1:
b = input()
a = BPL(b)
i += 1
What is problem with my code?

why you have counted No, wide, Dead ball?? You should count only Out ball and 1-6 runs ball.

What’s the problem?


#include<set>
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#include<climits>
#include<cstring>
#include<cmath>
#include<unordered_map>
#include<sstream>
#include<cmath>
#include<iomanip>
#include<numeric>
using namespace std;

bool is(int n){
	for(int i=2;i<=sqrt(n);i++){
		if(!(n%i)) return false;
	}
	return true;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	while(n){
		string s;
		cin>>s;
		int c=0;
		for(int i=0;i<s.size();i++){
			if(s[i]!='W' && s[i]!='N' && s[i]!='D'){
				c++;
			}
		}
		if(c==6){
			cout<<"1 OVER"<<endl;
		}
		else if(c>6){
			if(c/6==1){
				cout<<c/6<<" OVER ";
			}
			else{
				cout<<c/6<<" OVERS ";
			}
			if(c%6==1){
				cout<<c%6<<" BALL"<<endl;
			}
			else{
				cout<<c%6<<" BALLS"<<endl;
			}
		}
		else{
			if(c%6>1){
				cout<<c%6<<" BALLS"<<endl;
			}
			else{
				cout<<c%6<<" BALL"<<endl;
			}
		}
		n--;
	}
}
T=int(input())
for i in range(T):
	case=input()
	o="OVER"
	b="BALL"
	lm=0
	for char in case:
		if char not in ("WDN"):
			lm+=1
	lo=" "+str(lm//6)
	lb=" "+str(lm%6)
	if int(lo)>1:
		o+="S"
	if int(lb)>1:
		b+="S"
	if int(lb)==0:
		print(lo,o)
	elif int(lo)==0:
		print(lb,b)
	else:
		print(lo,o+lb,b)

where is the problem?
when I submit, it says wrong answer.But the expected output and my code’s output look the same to me.

Same problem… Look at the code below:

test_case = int(input())
for i in range(test_case):
S = input()
if “N” or “W” or “D” in S:
S = S.replace(‘N’, ‘’)
S = S.replace(‘W’, ‘’)
S = S.replace(‘D’, ‘’)
arg1 = (len(S)%6 )
arg2 = ((len(S) // 6))
if arg1 == 0:
arg1 = “”
elif arg1 and arg1==1:
arg1 = " 1 BALL"
else:
arg1 = " “+str(arg1) + " BALLS”
if arg2 == 0:
arg2 = “”
elif arg2 and arg2==1:
arg2 = " 1 OVER"
else:
arg2 = str(arg2) + " OVERS"
print(arg2 + arg1)

what’s wrong with the code?

image
what is this?..

Your submission was printing spaces at the end of each line.

This problem had strict spacing requirements as it is a relatively old problem on Toph. However, that has been updated and your submission has been rejudged.

https://toph.co/s/706085

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
int main()
{
    int t,j,i;
    cin>>t;
    int ball[t];
    for(j=0; j<t; j++)
    {
        ball[j]=0;
        char str[50];
        fflush(stdin);
        fgets(str, 50, stdin);
        for(i=0; str[i+1]!='\0'; i++)
        {
            if(str[i]!='N'&&str[i]!='W'&&str[i]!='D')
                ball[j]++;
        }
    }
    for(j=0; j<t; j++){
        if(ball[j]>5 && ball[j]%6==0)
            cout<<ball[j]/6<<" OVER "<<endl;
        else if(ball[j]/6==1)
            cout<<1<<" OVER ";
        else if(ball[j]/6>=1)
            cout<<ball[j]/6<<" OVERS ";
        if(ball[j]%6==1)
            cout<<1<<" BALL"<<endl;
        else if(ball[j]%6>1)
            cout<<ball[j]%6<<" BALLS"<<endl;
    }
}

This code produce output correctly in CodeBlocks IDE, but when I submit here it shows the outputs like the second image. Can you please tell me what is causing this problem?
image

a = int(input())

li = ["0","1","2","3","4","5","6"]

for i in range(a):

    s = 0

    x = input()

    # print(x)

    y = []

    for i in range(len(x)):

        y.append(x[i])

    # print(y)

    for i in range(len(y)):

        if (y[i]) in li:

            # print("YES")

            # print(y[i])

            s = s+1

    o = 0

    b = 0        

    while s>=6:

        o = o+1

        s = s-6

    b = s

    if b ==0:

        if o == 1:

            print(f"{o} OVER")

        else:

            print(f"{o} OVERS")

    elif o == 0:

        if b == 1:

            print(f"{b} BALL")

        else:

            print(f"{b} BALLS")

    else:

        if o == 1 and b == 1:

            print(f"{o} OVER {b} BALL")

        elif o == 1:

            print(f"{o} OVER {b} BALLS")

        else:

            print(f"{o} OVERS {b} BALL")

Whats the problem here ???
I think there is a proble in test cases line 2
There whould be 0 rather than O

1 Like

Looks like you were able to solve the problem. Nice work.