DCP-32 runtime error

Dev Skill archived problems can be discussed here.

DCP-32 runtime error

by nazib007 » Thu Jan 25, 2018 4:30 pm

Code is bellow :cry: :cry:
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

Re: DCP-32 runtime error

by BishalG » Thu Jan 25, 2018 5:07 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:

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
User avatar
 
Posts: 43
Joined: Tue Jan 17, 2017 10:10 pm


Who is online
Users browsing this forum: No registered users and 0 guests
cron