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
(가장 나이가 적은 수, 가장 나이가 많은 수, 둘의 차이)를 출력하는 문제이다.
더보기
![](https://blog.kakaocdn.net/dn/CPzPn/btqCX9mTwdf/RuIJOQeOse1EBuhzf6Z9sk/img.png)
내 코드
# 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)
|
![](https://blog.kakaocdn.net/dn/CPzPn/btqCX9mTwdf/RuIJOQeOse1EBuhzf6Z9sk/img.png)
반응형
'알고리즘 > 코드워' 카테고리의 다른 글
[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 |