나는 이렇게 학습한다/Algorithm & SQL
1002. Twice as old
daco2020
2022. 10. 3. 18:05
Your function takes two arguments:
- current father's age (years)
- current age of his son (years)
Сalculate how many years ago the father was twice as old as his son (or in how many years he will be twice as old). The answer is always greater or equal to 0, no matter if it was in the past or it is in the future.
Solution:
def twice_as_old(dad_years_old, son_years_old): return abs(dad_years_old - son_years_old*2)