Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
data.discard() solution in Clear category for Shorter Set by kdim
def remove_min_max(data: set[int], total: int) -> set[int]:
for _ in range(total):
data.discard(min(data, default=None))
data.discard(max(data, default=None))
return data
print("Example:")
print(remove_min_max({4, 5, 6, 7}, 1))
assert remove_min_max({8, 9, 18, 7}, 1) == {8, 9}
assert remove_min_max({8, 9, 7}, 0) == {8, 9, 7}
assert remove_min_max({8, 9, 7}, 2) == set()
assert remove_min_max({1, 2, 7, 8, 9}, 2) == {7}
assert remove_min_max(set(), 1) == set()
print("The first mission is done! Click 'Check' to earn cool rewards!")
Jan. 22, 2023
Comments: