알고리즘/코드워
[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([16, 22, 31, 44, 3, 38, 27, 41, 88])
print(answer)
answer = difference_in_ages([5, 8, 72, 98, 41, 16, 55])
print(answer)
|

반응형