# WA in SWPDGT

``````t = int(input())

while(t):

arr = [int(x) for x in input().split()]
A = arr
B = arr

a = A // 10
b = A % 10
c = B // 10
d = B % 10
if(A < 10 and B < 10):
print(A + B)
elif(A < 10 and B >= 10):
print(max(c+b*10+d, d+c*10+b, b+c*10+d))
elif(B < 10 and A >= 10):
print(max(a+b*10+d, d+b*10+a, a+d*10+b))
else:
print(max(d*10+b+c*10+a, c*10+b+a*10+d, a*10+c+b*10+d, a*10+d+c*10+b))
t -= 1
``````

your code is giving wrong output for this test case :-
1
19 7

correct output :- 80
you cannot swap digits of same number , you can’t swap 1 with 9 , you can swap 7 with either 9 or 1 in order to get max value.

@pkpawan123 thank you for the test case,but the problem was in 2nd elif where i was multiplying by 10 the ones digit,whichshould have been the test digit. Thanks for the reply man it is resolved.

1 Like

nice you did it yourself .

https://www.codechef.com/viewsolution/32753766
I need help y is it not working?

your program is failing for these test cases
: -
1
7 9
expected output -16
this is because you are checking the condition of (a<10 and b<10) at the end , you should check this condition before checking (b<10) .
2nd test case that is failing is
1
69 67
expected output-163
as we can do atmost 1 swap we will swap 9 with 6 so now numbers are 66 and 97 so output is 163.

1 Like

thanks for the help bro!!

1 Like

CodeChef: Practical coding for everyone Still i cant figure out whats wrong.

bro your code is providing correct output to all my cases , i was not able to find test case that fail . i would recommend you to check out the editorial of this question.

1 Like

No problem ,thanks for the reply.

1 Like