Skip to content

Instantly share code, notes, and snippets.

@sujitmhj
Created April 28, 2019 05:06
Show Gist options
  • Save sujitmhj/bb3a9efaf7fd35f6c11a06f1fa9950cd to your computer and use it in GitHub Desktop.
Save sujitmhj/bb3a9efaf7fd35f6c11a06f1fa9950cd to your computer and use it in GitHub Desktop.
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def check_triangle(numbs):
total = sum(numbs)
for i in range(3):
item = numbs[i]
two_sum = total - item
if item >= two_sum:
return False
return True
def solution(A):
# 1, 2, 3, 4, 5, 6
if len(A) < 3:
return 0
A = sorted(A)
for i in range(len(A)-2):
if check_triangle(A[i:i+3]):
return 1
return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment