aboutsummaryrefslogtreecommitdiff
path: root/type_of_triangle.py
blob: 17dd7dd6b11fd1df6a00ca739ef982f4d7fc0270 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 3024. Type of Triangle

"""
you are given a 0-indexed integer array 'nums' of size 3 which can form the
sides of a triangle. return a string representing the type of triangle that
can be formed, or none if it cannot form a triangle.
"""


class Solution(object):
    def triangleType(self, nums):
        """
        :type nums: List[int]
        :rtype: str
        """
        nums.sort()
        if nums[2] >= nums[0] + nums[1]:
            return "none"
        if nums[0] == nums[2]:
            return "equilateral"
        if nums[0] == nums[1] or nums[1] == nums[2]:
            return "isosceles"
        return "scalene"


if __name__ == "__main__":
    obj = Solution()
    print(obj.triangleType(nums=[3, 3, 3]))
    print(obj.triangleType(nums=[3, 4, 5]))