Skip to content

Instantly share code, notes, and snippets.

@Cspeisman
Last active December 19, 2015 02:49
Show Gist options
  • Save Cspeisman/5886045 to your computer and use it in GitHub Desktop.
Save Cspeisman/5886045 to your computer and use it in GitHub Desktop.
def valid_triangle?(a, b, c)
s = (a + b + c) / 2.0
not_triangle = (s - a) * (s - b) * (s - c)
if not_triangle <= 0
return false
end
arr_s = [a,b,c].sort
if ((arr_s[0]**2) + (arr_s[1]**2) == (arr_s[2]**2))
return true
elsif (a == b && b == c)
return true
elsif (a == b || a == c || b == c)
return true
else
return false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment