0
Can anyone optimize this code.
for _ in range(int(input())): p,t = map(int,input().split()) i=0 if(p==t): print(0) elif(p>t): while(p>t): i+=1 p-=2 t-=1 print(i) elif(p<t): while(p<t): i+=1 p+=2 t+=1 print(i) Input 3 1 3 2 1 1 1 Output 2 1 0
9 Answers
+ 4
Just put
1st two lines plus
print(abs(p-t) )
+ 2
Can you please summarize what the code is supposed to do?
Print the absolute difference of a pair of numbers?
0
Lisa it's a codeshef problem in which there's is a policeman and a theif they running on a same direction but policeman can run 2 steps in 1 sec and theif can run 1 step in 1 second .so we want to tell how much policeman take to catch the theif.
As you see first input 1 3 here in 1 position policeman are there and in 3 position theif are then we want to tell in how much second policeman will catch the theif.
Or you can search on google if you want full question
Police and theif codeshef problem.
0
Jayakrishnaš®š³ you can also search on google for better understanding of question
0
If you need help, it is actually *your* job to explain what you are trying to do ā and not ours to guess and google it š
0
0
Lisa okay but i tried my best to explain . thank you giving your time.
0
Akash Gupta Your summary is fine, I just wanted to point out that the task description is important so we know.what the code is about :)
0
Akash Gupta why I need to search?
Between are you asking about this question? In DM..
Is it not solved?