Skip to content

Instantly share code, notes, and snippets.

@zombor
Created January 9, 2012 04:37
Show Gist options
  • Save zombor/1581140 to your computer and use it in GitHub Desktop.
Save zombor/1581140 to your computer and use it in GitHub Desktop.
def triangle(a, b, c)
raise TriangleError unless valid_triangle?(a,b,c)
[:equilateral, :isosceles, :scalene][[a,b,c].uniq.size - 1]
end
def valid_triangle?(a,b,c)
ax,bx,cx = [a,b,c].sort
ax + bx > cx
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment