Created
April 10, 2013 20:12
-
-
Save stomatocode/5358029 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
# test to see if valid triangle | |
def valid_triangle?(a, b, c) | |
if ((a == 0 or b == 0 or c == 0) or (a == nil or b == nil or c == nil)) | |
return false | |
end | |
if a + b > c | |
return true | |
elsif a + c > b | |
return true | |
elsif b + c > a | |
return true | |
else | |
return false | |
end | |
end | |
puts valid_triangle?(1,6,0) | |
puts valid_triangle?(11,1,11) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment