Yes this is wrong,
2+9 is correct but you cant subtract an odd number.
You have to subtract an even number.
and what about 2+7+1?
To achieve 10 from 2 ,
a=5 b=2
we can do, 2+a+a-b = 10
you can’t change a or b more than once.
oh! i get it now.
ohh sorry My Bad I got it now
for testcase x>y ans is should be ans=0 right ?
eg
x=4 y=0;
means he has already achieved y at certain point of time and now current level of cleaning is x=4
so what i mean is does he has to reduce level of cleaning to achieved y ? @aman1108
how can this problem as real world problem. why any one wants to reduce his work
to achieved something which he already done.
Can anyone please tell me some examples of 3 moves please??
x=1 y=7
first we add 7 to x hence it becomes 8 now.then we subtract 8 from x now x becomes 0 and then again we add 7 to x which becomes 7. so a=7 and b=8.
When X<Y it will take 1 operation when difference is odd, 2 when difference is even but not divisible by 4 else 3,
cananyone explain this?
x=4 y=0 , means that in how many minimum steps you would take to go from 4 (x) to 0 (y).
Thanks bro
but bro why it can not be happened he has already cleaned his lab and now he is at x=4
which is current .
what i mean he is already done minimum steps to achieved y
No we are not assuming that its already done.
Problem is to go from x to y in minimum steps.
Now you understood reason for 3 moves ?
Yes, for every X and Y, where Y>X, and (Y-X) is even and divisible by 4, we will get 3 operations.
For eg: X=4, Y=20
now d=(Y-X)=16 which is even and divisible by 4.
Since, odd + odd=even, we can consider a=17.
4+17+17=38.
Now we can subtract any even number to convert 38 to 20,since, even-even=even.
b=18 does our work. So b=18.
Ergo, a=17,b=18, and it took us 3 operations(minimum).