BPL Mubarak

Limits: 1s, 512 MB

Bangladesh Premier League Sylhet for the first time. First, match Sylhet Sixers vs Dhaka Dynamites. Dhaka Dynamites’s Batting is too Good. There are many people are come Sylhet International Stadium to see this match, you are one of them.


This is a companion discussion topic for the original entry at https://toph.co/p/bpl-mubarak
#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?