Skip to content

Instantly share code, notes, and snippets.

@xiaods
Created November 14, 2013 01:32
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 xiaods/7459742 to your computer and use it in GitHub Desktop.
Save xiaods/7459742 to your computer and use it in GitHub Desktop.
def triangle(a, b, c)
raise TriangleError if [a,b,c].min <= 0
x, y, z = [a,b,c].sort
raise TriangleError if x + y <= z
[:equilateral,:isosceles,:scalene].fetch([a,b,c].uniq.size - 1)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment