Shorter Set

Shorter Set

In a given set of integers, you need to remove minimum and maximum elements.

The second argument tells how many min and max elements should be removed.

Input: Two arguments. Set of ints and int.

Output: Set of ints

Example:

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}

How it’s used: (math is used everywhere)

Precondition: ints in the set is between -1000 and 1000; the second argument is between -1000 and 1000

40