Skip to content

Instantly share code, notes, and snippets.

@joelturnbull
Created June 18, 2011 00:51
Show Gist options
  • Save joelturnbull/1032674 to your computer and use it in GitHub Desktop.
Save joelturnbull/1032674 to your computer and use it in GitHub Desktop.
Triangle Ruby Koan Solution
# The sum of the lengths of any two sides of a triangle always exceeds the length of the third side
raise TriangleError if ( vertices.inject(0) { |sum,vertex| sum += vertex } - vertices.max <= vertices.max )
return :equilateral if ( vertices.uniq.size == 1 )
return :isosceles if ( vertices.uniq.size == 2 )
return :scalene
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment