0
FARMING FIGURE
you are given N sticks of varying lengths. you need to determine whether it is possible to form a polygon of positive area by arranging them in some order.for example,if three sticks of lengths 1,1,1 are given we can easily see that we can form a triangle by arranging them in order. on the other hand, if the sticks have length 1,2,1 then we cannot form a polygon of non zero area these.
6 Answers
+ 2
Yeah so find the longest stick, add up all the others, and see if the longest is shorter than the rest.
+ 1
3 sticks have to obey the triangle inequality: One side cannot be longer (or equal) than the sum of the other two.
n sticks have to obey the n-gon inequality: The longest side cannot be longer (or equal) than the sum of all the rest.
0
i want to write the code for this question in a programming language
0
#Python - Enter stick lengths seperated by space
sticks=list(map(int,input().split()))
#print(sticks)
longestStick=max(sticks)
sticks.remove(longestStick)
lengthOfRest=sum(sticks)
#print(longestStick,lengthOfRest)
if lengthOfRest<=longestStick:
print('No positive area')
else:
print('Has positive area')
0
constraints. . 1<=N<=100
Length of any stick will be less than 100
- 1
i need the program