Computer Science, asked by surbhi1437, 9 days ago

equation "x=y", for example, "111-12", you need to add pluses inside x to make the equation correct. In our example "111=12", we can add one plus "11+1=12" and the equation becomes correct. You need to find the minimum number of pulses to add to x to make the equation correct. If there is no answer print -1. Note that the value of y won't exceed 5000. The numbers in the correct equation may contain arbitrary amount of leading zeros. coding in python​

Answers

Answered by dreamrob
0

Program:  

x = int(input("Enter the value of x : "))  

y = int(input("Enter the value of y : "))  

if x == y and y <= 5000:  

  print("The equation is correct")  

elif x < y and y <= 5000:  

  print("We need to add", (y - x),"to x to make the equation correct")  

else:  

  print("-1")

Output 1:  

Enter the value of x : 11  

Enter the value of y : 12  

We need to add 1 to x to make the equation correct

Output 2:  

Enter the value of x : 23  

Enter the value of y : 23  

The equation is correct

Output 3:  

Enter the value of x : 23  

Enter the value of y : 12  

-1

Similar questions