Skip to content

Instantly share code, notes, and snippets.

@vuorejo1
Created June 26, 2013 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vuorejo1/5870536 to your computer and use it in GitHub Desktop.
Save vuorejo1/5870536 to your computer and use it in GitHub Desktop.
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