Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
filter and filterfalse solution in Clear category for The Ship Teams by tokyoamado
from itertools import filterfalse
is_second = lambda s: 20 <= s[1] <= 40
def two_teams(sailors):
items = sailors.items()
first, second = filterfalse(is_second, items), filter(is_second, items)
return [
sorted([x[0] for x in first]),
sorted([x[0] for x in second])
]
Sept. 27, 2018