-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d7f923
commit 1ec9a62
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" | ||
https://www.codewars.com/kata/511f11d355fe575d2c000001/train/python | ||
Two Oldest Ages | ||
The two oldest ages function/method needs to be completed. It should take an array of numbers as its argument and return the two highest numbers within the array. The returned value should be an array in the format [second oldest age, oldest age]. | ||
The order of the numbers passed in could be any order. The array will always include at least 2 items. | ||
For example: | ||
two_oldest_ages([1, 3, 10, 0]) # should return [3, 10] | ||
""" | ||
|
||
def two_oldest_ages(ages): | ||
return sorted(ages)[-2:] | ||
|
||
""" | ||
Sample Tests | ||
Test.assert_equals(two_oldest_ages([1, 5, 87, 45, 8, 8]), [45, 87]) | ||
Test.assert_equals(two_oldest_ages([6, 5, 83, 5, 3, 18]), [18, 83]) | ||
Test.assert_equals(two_oldest_ages([10, 1]), [1, 10]) | ||
""" |