Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Ship Teams by Merzix
def two_teams(sailors):
ans = [[],[]]
for sailor, y in sailors.items():
ans[not (y < 20 or y > 40)].append(sailor)
return list(map(sorted, ans))
if __name__ == '__main__':
assert two_teams({
'Smith': 34,
'Wesson': 22,
'Coleman': 45,
'Abrahams': 19}) == [
['Abrahams', 'Coleman'],
['Smith', 'Wesson']
]
assert two_teams({
'Fernandes': 18,
'Johnson': 22,
'Kale': 41,
'McCortney': 54}) == [
['Fernandes', 'Kale', 'McCortney'],
['Johnson']
]
Sept. 1, 2018
Comments: