Skip to content

Commit

Permalink
Solve Two Oldest Ages 7kyu
Browse files Browse the repository at this point in the history
  • Loading branch information
cruisediary committed Mar 8, 2020
1 parent 2d7f923 commit 1ec9a62
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions 7kyu/Two Oldest Ages/Two Oldest Ages.py
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])
"""

0 comments on commit 1ec9a62

Please sign in to comment.