Problem 10 Linear Function checker problem

Back to Problem Solutions forum

Suman Dutta     2020-05-04 08:07:00

list=[[-574 ,-17585, -236, -7107], [-695 ,32600 ,-285 ,12920], [398 ,-28648, -726 ,53404], [486 ,-12344 ,-33, 1669], [932 ,-68353 ,233, -16627], [-619, -33341 ,-870, -47146], [-643, -39350 ,355, 22526], [584 ,-18520, 982, -31654], [-254, 26 ,482 ,-2918], [-803 ,60276, -485 ,36426]]; for i in range(0,10): x1=list[i][0]; y1=list[i][1]; x2=list[i][2]; y2=list[i][3]; a=int((y2-y1)/(x2-x1)); b=int(y1-x1*(a)); print('(',a,b,')','\t');

solution: ( 31 209 ) ( -48 -760 ) ( -73 406 ) ( -27 778 ) ( -74 615 ) ( 55 704 ) ( 62 516 ) ( -33 752 ) ( -4 -990 ) ( -75 51 )

Solution to this problem is same.i have checked 5 times.Checker is giving same answer yet saying incorrect or failed

sirpetethegreat     2020-05-05 16:22:05

The issue might just be spacing. You have spaces between the parentheses and values, but the checker will be looking for no spaces there and spaces between ordered pairs, as

(31 209) (-48 -760) (-73 406) (-27 778) (-74 615) (55 704) (62 516) (-33 752) (-4 -990) (-75 51)

assuming your answers are correct.

The only other potential issue I can see is that you are using the int value of slope in your calculation for intercept, which could (theoretically) cause an answer to be slightly off. From a purely mathematical perspective it's better to wait until you have both slope and intercept as floating point before converting to int. That's not likely to cause as much grief, though.

Suman Dutta     2020-05-06 09:52:35

thank you... yes spaces were the problem in solution

Please login and solve 5 problems to be able to post at forum