Last active
November 10, 2017 15:05
-
-
Save jspblm/92dfa0d63d2b4a0721451b7f8155939f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" A simple script to calculate the diference within two courses """ | |
def course_delta(c1, c2): | |
""" Calculate the diference within two consecutive courses """ | |
if c2 < c1: | |
# The function expects that c2 is always greater than c1 | |
temp = c2 | |
c2 = c1 # switch the values of c1 and c2 | |
c1 = temp | |
delta = c2 - c1 | |
if delta > 180: | |
# When the diference is greater than 180 degrees calculate the complement of course two. (base on a 360 degrees) | |
d = 360 - c2 | |
delta = d + c1 | |
return delta | |
else: | |
return delta | |
################################ When course_two - course_one < 180 degrees | |
course_one = 10 | |
course_two = 80 | |
course_change = course_delta(course_one, course_two) | |
print('course_change = %s ' % course_change) | |
validation = 60 | |
if course_change >= validation: | |
print('The difference within course one and course two is greater than %s, When course_two - course_one < 180 degrees ' % (validation,)) | |
################################ When course_two - course_one > 180 degrees | |
course_one = 25 | |
course_two = 320 | |
course_change = course_delta(course_one, course_two) | |
print('course_change = %s' % course_change) | |
validation = 60 | |
if course_change >= validation: | |
print('The difference within course one and course two is greater than %s, When course_two - course_one > 180 degrees ' % (validation,)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment