Programming problem in python


Sample input:

5
3 2 3
100 100 100
50 49 49
10 30 20
1 1000000000 1000000000

Sample output:

YES
3 2 1
YES
100 100 100
NO
NO
YES
1 1 1000000000

My code for this problem:

for _ in range(int(input())):
    x,y,z = map(int,input().split())
    if x == y == z:
        print("YES")
        print(x,y,z,sep=" ")
    elif x == y or x == z or y == z:
        if [x,y,z].count(max(x,y,z)) == 2:
            a = [x,y,z]
            a.sort()
            if a[0] > 1:
                print(max(x,y,z),a[0],a[0]-1,sep=" ")
            else:
                print(max(x,y,z),a[0],a[0],sep=" ")
        else:
            print("NO")
    else:
        print("NO")

Output is okay for sample input.But am i solving this problem correctly?

ufff :sob: :sob: :sob:
I was wrong .I forgot to add print("YES") before those print statement.
Always found me dumb :sob:

1 Like

You have done a good job!
Remove th first line of your code:

for _ in range(int(input())):

Instead replace it with:

num_tests = int(input("number of tests\n"))

for i in range(num_tests):
#The rest of your code

At the execution you have to enter the hole Block:

5
3 2 3
100 100 100
50 49 49
10 30 20
1 1000000000 1000000000

at once!

It seems to work! Hopefully!

1 Like