Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
difference_update solution in Clear category for Shorter Set by Sim0000
def remove_min_max(data: set, total:int) -> set:
for _ in range(total):
if not data: break
data -= {min(data), max(data)}
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. 31, 2022
Comments: