Created
February 12, 2012 18:02
-
-
Save cammckinnon/1809940 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def ArithGeo(arr): | |
diff = arr[1] - arr[0] | |
multiple = arr[1]/arr[0] | |
isarith = True | |
isgeom = True | |
for i in range(0,len(arr)-1): | |
d = arr[i+1] - arr[i] | |
if d!=diff: | |
isarith = False | |
m = arr[i+1] / arr[i] | |
if m!=multiple: | |
isgeom = False | |
if isarith: | |
print "Arithmetic" | |
elif isgeom: | |
print "Geometric" | |
else: | |
print -1 | |
# this call is needed to test your function | |
# keep this when you submit your code | |
ArithGeo(arr) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment