알고리즘/코드워

[python]Find the Difference in Age between Oldest and Youngest Family Members

(ㅇㅅㅎ) 2020. 3. 27. 21:35
728x90
반응형

https://www.codewars.com/kata/5720a1cb65a504fdff0003e2/train/python

 

Codewars: Train your coding skills

Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential.

www.codewars.com

(가장 나이가 적은 수, 가장 나이가 많은 수, 둘의 차이)를 출력하는 문제이다.

더보기

내 코드

# My Code
def difference_in_ages(ages):
    youngest_age = min(ages)
    oldest_age = max(ages)
    return (youngest_age, oldest_age, oldest_age-youngest_age)
 
def difference_in_age1(ages):
    return (min(ages), max(ages), max(ages)-min(ages))
 
if __name__=='__main__':
    answer = difference_in_ages([16223144338274188])
    print(answer)
    answer = difference_in_ages([587298411655])
    print(answer)
 
반응형

'알고리즘 > 코드워' 카테고리의 다른 글

[python]Is it even?  (0) 2020.03.30
[python]Find the first non-consecutive number  (0) 2020.03.28
[python]All Star Code Challenge#18  (0) 2020.03.26
[python]Will you make it?  (0) 2020.03.24
[python]Removing Elements  (0) 2020.03.20