We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
deftriangulate(x):a,b,c=xifa+b>c:ifa+c>b:ifb+c>a:returnTruereturnFalsedefmaximumPerimeterTriangle(sticks):# Write your code heresides=list(combinations(sticks,3))sides=sorted(sides,key=sum,reverse=True)sides=list(filter(triangulate,sides))ifnotsides:return[-1]valid=list({xforxinsidesifsum(x)==sum(sides[0])})iflen(valid)==1:returnsorted(valid[0])valid=sorted(valid,key=max,reverse=True)valid=list(filter(lambdax:max(x)==max(valid[0]),valid))iflen(valid)==1:returnsorted(valid[0])valid=sorted(valid,key=min,reverse=True)valid=list(filter(lambdax:min(x)==min(valid[0]),valid))returnsorted(valid[0])
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Maximum Perimeter Triangle
You are viewing a single comment's thread. Return to all comments →
python3