Created
June 18, 2011 00:51
-
-
Save joelturnbull/1032674 to your computer and use it in GitHub Desktop.
Triangle Ruby Koan Solution
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
# 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