Question: def no _ three _ in _ line ( n ) : points = [ ] x , y = 0 , 1 while len

def no_three_in_line(n): points =[] x, y =0,1 while len(points)< n: if (x + y)%3!=0: # This avoids simple collinear arrangements points.append((x, y)) y +=1 if y == n: x +=1 y =0 return points def check_no_three_in_line(points): for i in range(len(points)): for j in range(i +1, len(points)): for k in range(j +1, len(points)): # Check for collinearity using the determinant method if (points[i][0]- points[j][0])*(points[i][1]- points[k][1])==\(points[i][1]- points[j][1])*(points[i][0]- points[k][0]): return False return True # Example usage and testing for n in range(1,10): points = no_three_in_line(n) print(f"Points for n={n}: {points}") print("No three points in line:", check_no_three_in_line(points))1:Unit testing: no_three_in_line()0/8 Checking no_three_in_line(integer) if returns correct answers Your output Points for n=1: [(0,1)] No three points in line: True Points for n=2: [(0,1),(1,0)] No three points in line: True Points for n=3: [(0,1),(0,2),(1,0)] No three points in line: True Points for n=4: [(0,1),(0,2),(1,0),(1,1)] No three points in line: True Points for n=5: [(0,1),(0,2),(0,4),(1,0),(1,1)] No three points in line: False Points for n=6: [(0,1),(0,2),(0,4),(0,5),(1,0),(1,1)] No three points in line: False Points for n=7: [(0,1),(0,2),(0,4),(0,5),(1,0),(1,1),(1,3)] No three points in line: False Points for n=8: [(0,1),(0,2),(0,4),(0,5),(0,7),(1,0),(1,1),(1,3)] No three points in line: False Points for n=9: [(0,1),(0,2),(0,4),(0,5),(0,7),(0,8),(1,0),(1,1),(1,3)] No three points in line: False Test feedback [FAIL] input =6 Your function returned a set of 3+ collinear points! 2:Comment 1/1 At least one # style comment in file Test feedback Comment detected! 3:Header 1/1 Header exists in file Test feedback Header detected! 4:Bonus: 1.8n+ points 0/1 Bonus: your code finds 1.8n or more points Your output Points for n=1: [(0,1)] No three points in line: True Points for n=2: [(0,1),(1,0)] No three points in line: True Points for n=3: [(0,1),(0,2),(1,0)] No three points in line: True Points for n=4: [(0,1),(0,2),(1,0),(1,1)] No three points in line: True Points for n=5: [(0,1),(0,2),(0,4),(1,0),(1,1)] No three points in line: False Points for n=6: [(0,1),(0,2),(0,4),(0,5),(1,0),(1,1)] No three points in line: False Points for n=7: [(0,1),(0,2),(0,4),(0,5),(1,0),(1,1),(1,3)] No three points in line: False Points for n=8: [(0,1),(0,2),(0,4),(0,5),(0,7),(1,0),(1,1),(1,3)] No three points in line: False Points for n=9: [(0,1),(0,2),(0,4),(0,5),(0,7),(0,8),(1,0),(1,1),(1,3)] No three points in line: False Test feedback [FAIL] input =4 Your function did not return enough points!eturn a set of points that satisfy the requirements in a reasonable amount of computational time. The function should take in as a parameter a positive integer () and return a list of integer coordinates such that no three points form a straight line. Please comment out any input() statements before submitting. It's okay to have print() statements, but they will be ignored. You may use ChatGPT or similar AI tools to complete this lab. This is the ONE TIME in ENGR 102 that its okay to use AI! For grid sizes up to =46, the conjectured largest set of points is 2. This can be difficult to solve with code, so your submission only needs to find a minimum of points. If your code finds 1.8 or more points, you will receive 1 bonus point. When debugging, remember DRIFT: discover, reproduce, isolate, fix, and test. Its a good idea to come up with several test cases to test your code before you start making changes to ChatGPTs solution. Here are examples to get you started (there are many correct answers): no_three_in_line(3) may return [[0,0],[1,1],[1,2],[2,0]] no_three_in_line(4) may return [[0,0],[0,1],[1,1],[1,2],[2,0],[3,2]] Example for the bonus: no_three_in_line(3) may return [[0,0],[0,1],[1,0],[1,2],[2,1],[2,2]]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!