물음표 살인마의 개발블로그

알고리즘 문제/CodeWar

Area or Perimeter

BEstyle 2022. 9. 26. 12:51

DESCRIPTION:

You are given the length and width of a 4-sided polygon. The polygon can either be a rectangle or a square.
If it is a square, return its area. If it is a rectangle, return its perimeter.

Example(Input1, Input2 --> Output):

6, 10 --> 32
3, 3 --> 9

Note: for the purposes of this kata you will assume that it is a square if its length and width are equal, otherwise it is a rectangle.


def area_or_perimeter(l , w):
    if l==w:
        return l**2
    return w*2+l*2

 

'알고리즘 문제 > CodeWar' 카테고리의 다른 글

Sort the odd  (0) 2022.09.27
Multiples of 3 or 5  (0) 2022.09.27
Break camelCase  (1) 2022.09.26
Count the smiley faces!  (1) 2022.09.26
Take a Ten Minutes Walk  (0) 2022.09.26