My issue
My code
# cook your dish here
a=int(input("enter first number"))
b=int(input("enter second number"))
m=a*b
n=a+b
print(m-n)
Problem Link: ABDIFF Problem - CodeChef
# cook your dish here
a=int(input("enter first number"))
b=int(input("enter second number"))
m=a*b
n=a+b
print(m-n)
Problem Link: ABDIFF Problem - CodeChef
@anayanimesh
The problem statement wants us to find absolute difference, (difference in magnitude only), between multiplication and addition of two numbers.
In your code, there seems to be a few problems.
Not taking inputs correctly: Both the numbers are to be taken in the same line which can be achieved using map function in Python.
Un-necessarily printing statements: In your code, there was no need to print something like;
enter first number
It will cause the code to give wrong answer even if the actual answer was correct. Pay attention to the problem statement, it specifies how inputs are to be taken and what is to be displayed as the output.
To add to this, you are simply printing difference between (a*b) and (a+b), which can be negative, instead of printing absolute difference which is always non-negative.
You can take a look at my code to get a better understanding.
# cook your dish here
a,b=map(int,input().split())
print(abs((a*b)-(a+b)))