Created
June 26, 2013 19:12
-
-
Save vuorejo1/5870536 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
def triangle(a, b, c) | |
kolmio = [a, b, c] | |
if a >= 0 || b >= 0 || c >= 0 | |
raise TriangleError.new('No side can be zero or negative') | |
end | |
if ((a >= b + c) || (b >= a + c) || (c >= a + b)) | |
raise TriangleError.new('No side can be equal or greater than sum of the other sides') | |
end | |
if kolmio.uniq.size == 1 then | |
return :equilateral | |
elsif kolmio.uniq.size == 2 then | |
return :isosceles | |
elsif kolmio.uniq.size == 3 then | |
return :scalene | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment