Created
March 5, 2012 21:36
-
-
Save JulianMiller/1981259 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
test | |
#median testing | |
def median(a,b,c): | |
if a>b or a==b: | |
if a<c or a==c: | |
return a | |
if a<b or a==b: | |
if a>c or a==c: | |
return a | |
if b>a or b==a: | |
if b<c or b==c: | |
return b | |
if b<a or b==a: | |
if b>c or b==c: | |
return b | |
if c>a or c==a: | |
if c<b or c==b: | |
return c | |
if c>b or c==b: | |
if c<a or c==a: | |
return c | |
print median(1,2,3) #2 | |
print median(1,1,3) #1 | |
print median(1,1,1) #1 | |
print median(3,2,1) #2 | |
print median(3,1,2) #2 | |
#so i started this way | |
def median (a,b,c): | |
if a==b or a==c: | |
return a | |
if b==c: | |
return b | |
#and i think that's all you need for == | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment