Byang's Additions

in line 4-7

if x<y:
	m=x-1
else:
	m=y-1

you are doing len - 1 here, right? which means m is the index of the last character of the strings.

then again in line 8 - 9

while m>0:
	m=m-1

you are again doing m = m - 1. So, Suppose if len = 2, then m becomes 0 here. means that you will miss m = 1 (the last character).

You are literally forgetting to check the last character of the string here. Your code will fail for simpliest possible inputs or inputs where byang fails to do the sum of the first numbers from the left.
Inputs like these,

# Input 1
5 5
# Input 2
126 459

Thank’s bro i change it while m>=0 now it has been accepted

1 Like
n=True
a,b=map(int, input().split())
a=str(a)
b=str(b)
for i in range(1,len(str(min(a,b)))+1):
    if int(a[-i])+int(b[-i])>=10:
        n=False
        break
print('Yes' if n==False else 'No')

It says ‘Runtime error’ in the 5th test.

Well, first of all, The first three lines are unnecessary. the split() method returns a list of strings itself. So, Just try writing this should do,

a, b = map(str, input().split()) # or simply,
a, b = input().split()

However, if you try to convert them into integer first, you will face RE. Python cannot handle such big integers. So, you must handle them as strings.

The Error looks somewhat like this,

>>> bigNum = 10 ** 10000 # 10^10000
>>> str = str( bigNum )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'str' object is not callable

Sorry @touhidur vaiya
Couldn’t relate. When I input the same codes in my python shell. The output is something like this-

>>> bigNum=10**10000
>>> str=str(bigNum)
>>> print(str)

Squeezed text(126 lines)

where clicking on the last line would show me 10^10000.

Also, I changed my code as below-

n=True
a,b=map(str, input().split())
for i in range(1,len(min(a,b))+1):
    if int(a[-i])+int(b[-i])>=10:
        n=False
        break
print('Yes' if n==False else 'No')

Still didn’t work

The Problem is in line 3,

len(min(a,b))

I think it should be like this,

min(len(a), len(b))
1 Like

It worked. Thank you.

num1, num2 = input().split()
num1 = list(map(int, num1))
num2 = list(map(int, num2))
result = []
for i in range(len(num1)):
try:
    a = num1[i]
    b = num2[i]
except IndexError:
    break
else:
    if a+b < 10:
        result.append(False)
    else:
        result.append(True)

if any(result):
print("Yes")
else:
print("No"

this code failed in test 6

My code gets wrong answer only for test case 7, I’ve done everything but still could not solve it, any and all help is welcome, thank you.

a,b = map(str,input().split())
n = min(len(a),len(b))
A = list(a)
A = a[::-1]
B = list(b)
B = b[::-1]
if int(A[0]) + int(B[0]) > 9:
	---print("Yes")
	---quit()
for i in range(n-1):
	---if int(A[i]) + int(B[i]) > 9:
		------print("Yes")
		------quit()
print("No")

Can guys please add C (GCC-4.8.5) which is in CB?
I can’t use most of the string function with the given C.

a,b=map(str,input().split())
c=[]
d=[]

for i in range(len(a)):
        c.append(int(a[i]))
for i in range(len(b)):
        d.append(int(b[i]))
        e=c[i]+d[i]
        if e>=10:
                print('Yes')
                break
        elif i==len(a)-1 or i==len(b)-1:
                print('No')

What’s the problem with this code?

Wrong Answer in 7th case. i have also tried considering the carry at the leftmost digit.But it doesnt work

 #include <stdio.h>

int main() {
	int i,count=0,a,b,c,d=0;
	scanf("%u%u",&a,&b);
	if(a>=b)
	{ c=a;
	 while(c!=0)
	 {
		 c=c/10;
		 count++;
	 }}
	else
	{   c=b;
		while(c!=0)
	 {
		 c=c/10;
		 count++;
	 }
	}
	for(i=1;i<=count;i++)
	{
	   if((a%10 +b%10)>10)
	   {d++;break;}
	   	   a=a/10;b=b/10;
	}
	if (d==0) printf("No");
	else printf("Yes");
	return 0;
}

//what is wrong in 6 case

#include<bits/stdc++.h>
#include
using namespace std;
int main(){

long long int a=0,b,i,j,min1,t1,t2;
string s1,s2;
cin>>s1>>s2;
t1=s1.size();
t2=s2.size();
min1=(t1,t2);
for(i=min1-1;i>=0;i–){

if(s1[i]-48+s2[i]-48>9){

//cout<<(s1[i]-48+s2[i]-48);
a=1;
cout<<“Yes”;
break;
}

}
if(a==0){

cout<<"No";

}
}

min1=(t1,t2) works exactly same as min1=t2. You can use ? : operation instead.

now also saw the wrong number …my mistAke was min1=min(t1,t2) no i write this but now saw wrong answer

#include<bits/stdc++.h>
#include<string>
using namespace std;
int main(){


long long int a=0,b,i,j,min1,t1,t2;
string s1,s2;
cin>>s1>>s2;
t1=s1.size();
t2=s2.size();
min1=min(t1,t2);
for(i=min1-1;i>=0;i--){

    if(s1[i]-48+s2[i]-48>9){
//cout<<(s1[i]-48+s2[i]-48);
        a=1;
        cout<<"Yes";
        break;
    }

}
if(a==0){

    cout<<"No";
}
}

There is a problem in the condition of while in your code.
The condition will be n!=0 || m!= 0.
Otherwise the first digits of the numbers will remain uncounted.

@touhidurrr
@hjr265

include <iostream>

using namespace std;

int main() {
    string a , b;
    cin >> a >> b;
    
    int n = a.size();
    
    for(int i = n ; i >= 0 ; i--){
        int x = (a[i]-'0')+(b[i]-'0');

        if(x>9){
        cout << "Yes"<<endl;
        return 0 ;
        }
    }
    
    cout << "No"<<endl;
    
}

why my code get wrong answer in the 6th test case

image
I don’t know what is wrong here :cry: Please help…

int main()
{
   int a,b,m,n,sum;
   scanf("%d %d",&a,&b);
   here:
   m=a%10;
   a=a/10;
   n=b%10;
   b=b/10;
   sum=m+n;
   if(m==0 && n==0)
   {
       printf("No");
   }
   else
   {if(sum<10)
    goto here;
    else printf("Yes");}
}

what’s wrong in this code…it’s showing wrong answer in the 7th test case…plz help me someone to spot the error…plz plz plz …