Skip to content

Instantly share code, notes, and snippets.

@xeonqq
Created September 4, 2015 11:57
Show Gist options
  • Save xeonqq/a5fc033c372ce53a3ad0 to your computer and use it in GitHub Desktop.
Save xeonqq/a5fc033c372ce53a3ad0 to your computer and use it in GitHub Desktop.
Determine whether a triangle can be built from a given set of edges.
def solution(A):
# write your code in Python 2.7
A.sort()
for i in xrange(len(A)-2):
if (((A[i] + A[i+1]) > A[i+2]) and ((A[i+2] + A[i+1]) > A[i]) and ((A[i+2] + A[i]) > A[i+1])):
return 1
return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment