Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: python
python:
- "3.5"

#command to run tests
script: nosetests
25 changes: 18 additions & 7 deletions point_pattern.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import math # I am guessing that you will need to use the math module
import pdb

from math import sqrt

"""
Below are 5 functions (we will talk about what
Expand Down Expand Up @@ -27,7 +30,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 = sum(abs(a-b) for a,b in zip(a,b)) # Add the algorithm to compute manhattan distance here
return distance
Copy link
Contributor

Choose a reason for hiding this comment

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

Very nice use of zip, abs, and sum. I suspect you will like the functional programming week.



Expand All @@ -49,7 +52,8 @@ def euclidean_distance(a, b):
distance : float
The Euclidean distance between the two points
"""
distance = None # Add the euclidean distance algorithm here
# pdb.set_trace()
distance = sqrt(sum((a - b) ** 2 for a, b in zip(a, b))) # Add the euclidean distance algorithm here
return distance


Expand Down Expand Up @@ -87,8 +91,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_shift + x # Add the logic to shift x here
y_new = y_shift + y# Add the logic to shift y here

return x_new, y_new

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

if a == b:
return True
else:
return False

def check_in(point, point_list):
"""
Expand All @@ -124,7 +130,11 @@ 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

if point in point_list:
return point
else:
return None # Add the logic to check if a point is in the point list here


def getx(point):
Expand All @@ -143,6 +153,7 @@ def getx(point):
: int or float
x coordinate
"""

return point[0]


Expand Down