Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions point_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def manhattan_distance(a, b):
distance : float
The Manhattan distance between the two points
"""
distance = None # Add the algorithm to compute manhattan distance here
distance = abs(a[0] - b[0]) + abs(a[1] - b[1])

return distance


Expand All @@ -49,7 +50,7 @@ def euclidean_distance(a, b):
distance : float
The Euclidean distance between the two points
"""
distance = None # Add the euclidean distance algorithm here
distance = math.sqrt((a[0]-b[0])**2+(a[1]-b[1])**2)
return distance


Expand Down Expand Up @@ -87,8 +88,8 @@ def shift_point(point, x_shift, y_shift):
x = getx(point)
y = gety(point)

x_new = None # Add the logic to shift x here
y_new = None # Add the logic to shift y here
x_new = x+x_shift
y_new = y+y_shift

return x_new, y_new

Expand All @@ -109,7 +110,7 @@ def check_coincident(a, b):
equal : bool
Whether the points are equal
"""
return None # Add the logic to check if coincident here
return a == b


def check_in(point, point_list):
Expand All @@ -124,7 +125,7 @@ def check_in(point, point_list):
point_list : list
in the form [point, point_1, point_2, ..., point_n]
"""
return None # Add the logic to check if a point is in the point list here
return (point in point_list) # Add the logic to check if a point is in the point list here
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you do not need to put point in point_list inside of the quotes (this casts the results to a tuple). This is a style thing primarily - a code checker (linter) would throw a warning. Obviously this still works, just a FYI.



def getx(point):
Expand Down