FARMING FIGURE | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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.

9th Aug 2018, 5:37 PM
BhUpii DhAps
BhUpii DhAps - avatar
6 Answers
+ 2
Yeah so find the longest stick, add up all the others, and see if the longest is shorter than the rest.
9th Aug 2018, 6:19 PM
Schindlabua
Schindlabua - avatar
+ 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.
9th Aug 2018, 6:14 PM
Schindlabua
Schindlabua - avatar
0
i want to write the code for this question in a programming language
9th Aug 2018, 6:17 PM
BhUpii DhAps
BhUpii DhAps - avatar
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')
9th Aug 2018, 6:21 PM
Louis
Louis - avatar
0
constraints. . 1<=N<=100 Length of any stick will be less than 100
9th Aug 2018, 6:22 PM
BhUpii DhAps
BhUpii DhAps - avatar
- 1
i need the program
9th Aug 2018, 6:20 PM
BhUpii DhAps
BhUpii DhAps - avatar