Back to General discussions forum
Hello There is a problem with the output in task 10. The data is correct as in the answer.
coordinates = [[-174, -9229, 678, 34223],
[189, 16159, 730, 61062],
[-731, 32651, 7, -1297],
[698, 31017, 322, 14473],
[-179, -10706, 410, 26990],
[-57, -4929, -147, -13749],
[632, -6700, -643, 7325],
[0, 751, -476, 275],
[-798, 48706, -773, 47206],
[956, 29071, 832, 25351],
[-161, -7376, -142, -6597]]
for i in coordinates:
a = int((i[3] - i[1]) / (i[2] - i[0]))
b = int(i[1] - a * i[0])
print('(%s %g)' % (a, b), end = " ")
Dima, Hi!
The code looks like it should or at least might work. Probably I'd use round(...)
instead of int(...)
in the
last lines just to be sure no errors will occur induced by floating-point representation...
Please include your exact answer and the "expected answer" the site shows to you when it says it incorrect... Otherwise it is a bit hard to tell what went wrong :(
BTW I suggest you shouldn't put input into array manually, I think this take significant time from you. Usually we can
read it as is (either from input()
or from special variable where it is stored enclosed in triple quotes, and then
split by newlines and by spaces.
like this (not mine solution):
def linear_function(...)
...
pass
cases = int(input())
for case in range(cases):
x1, y1, x2, y2 = [int(x) for x in input().split()]
print(linear_function(x1, y1, x2, y2), end=' ')