Skip to content

Instantly share code, notes, and snippets.

@kmandreza
Created June 30, 2012 23:52
Show Gist options
  • Save kmandreza/3026075 to your computer and use it in GitHub Desktop.
Save kmandreza/3026075 to your computer and use it in GitHub Desktop.
Triangle
def triangle(num1,num2,num3)
if num1 >= num2 + num3 || num2 >= num1 + num3 || num3 >= num2 + num1
:invalid
elsif num1 == num2 && num2 == num3 && num3 == num1
:equilateral
elsif num1 == num2 || num2 == num3 || num3 == num1
:isosceles
elsif num1 != num2 && num2 != num3 && num3 != num1
:scalene
end
end
puts triangle(8,8,8)
puts triangle(8,8,6)
puts triangle(8,9,10)
puts triangle(2,2,8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment