Python3

- Code: Select all
`n = int(input())`

c = 1

while n > 0:

x1 = int(input())

y1 = int(input())

x2 = int(input())

y2 = int(input())

moves = abs(x1 - x2) + abs(y1 - y2)

print("Case ", c,": ", moves, sep='',end='\n')

n -= 1

c += 1

2 posts
• Page **1** of **1**

Code is bellow

Python3

Python3

- Code: Select all
`n = int(input())`

c = 1

while n > 0:

x1 = int(input())

y1 = int(input())

x2 = int(input())

y2 = int(input())

moves = abs(x1 - x2) + abs(y1 - y2)

print("Case ", c,": ", moves, sep='',end='\n')

n -= 1

c += 1

**Posts:**1**Joined:**Thu Jan 25, 2018 4:26 pm

As mentioned in the problem statement that every test-case contain a single line with four space separated integers.

Since, Python is strict on spacing between integers, you have to scan a single line and parse 4 integers from there.

So, The code will be like this:

Since, Python is strict on spacing between integers, you have to scan a single line and parse 4 integers from there.

So, The code will be like this:

- Code: Select all
`n = int(input())`

c = 1

while n > 0:

inp = list( map(int,raw.input().split()) )

x1 = int(inp[0])

y1 = int(inp[1])

x2 = int(inp[2])

y2 = int(inp[3])

moves = abs(x1 - x2) + abs(y1 - y2)

print("Case ", c,": ", moves, sep='',end='\n')

n -= 1

c += 1

2 posts
• Page **1** of **1**

Who is online

Users browsing this forum: No registered users and 1 guest