categories: computer science
Welcome,
Below you will find a video with a detailed explanation of the algorithm for checking the triangle inequality condition. Its operation, time complexity, and usefulness. Below you will also find ready-to-use code that you can copy if needed.
Code:
boki = [10, 15, 12]
for i in range(len(boki)):
for j in range(len(boki) - i - 1):
if boki[j] > boki[j + 1]:
boki[j + 1], boki[j] = boki[j], boki[j + 1]
ostatni = boki[len(boki) - 1]
def warunek(boki):
global ostatni
if ostatni < boki[0] + boki[i]:
return True
print(warunek(boki))
Video:
Thank you for reading!
Read more