From 79dc451f15bb415a4c9c64b10b70946dd5de2180 Mon Sep 17 00:00:00 2001 From: pkadambi Date: Tue, 9 Feb 2016 18:18:16 -0700 Subject: [PATCH 1/2] uploading assignment --- point_pattern.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/point_pattern.py b/point_pattern.py index 9ae56ee..48b1754 100644 --- a/point_pattern.py +++ b/point_pattern.py @@ -27,7 +27,7 @@ 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 @@ -49,7 +49,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(abs(a[0]-b[0])+abs(a[1]-b[1])); return distance @@ -87,8 +87,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 # Add the logic to shift x here + y_new = y+y_shift # Add the logic to shift y here return x_new, y_new @@ -109,7 +109,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[0]==b[0]) and (a[1]==b[1]) # Add the logic to check if coincident here def check_in(point, point_list): @@ -124,7 +124,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 def getx(point): @@ -163,3 +163,4 @@ def gety(point): y coordinate """ return point[1] + \ No newline at end of file From 51c29b7a1a70caea834fe50af90c0f3cbbe181e4 Mon Sep 17 00:00:00 2001 From: pkadambi Date: Tue, 9 Feb 2016 18:44:05 -0700 Subject: [PATCH 2/2] Update point_pattern.py --- point_pattern.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/point_pattern.py b/point_pattern.py index 48b1754..df15569 100644 --- a/point_pattern.py +++ b/point_pattern.py @@ -49,7 +49,7 @@ def euclidean_distance(a, b): distance : float The Euclidean distance between the two points """ - distance = math.sqrt(abs(a[0]-b[0])+abs(a[1]-b[1])); + distance = math.sqrt(abs(a[0]-b[0])**2+abs(a[1]-b[1])**2); return distance @@ -163,4 +163,4 @@ def gety(point): y coordinate """ return point[1] - \ No newline at end of file +