Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- def doImmutableFilter(min_v, max_v, arr):
- '''Input list doesn't changes'''
- filtered_arr = list(filter(lambda x: not (min_v <= x <= max_v), arr))
- return filtered_arr + [0] * (len(arr) - len(filtered_arr))
- def doMutableFilter(min_v, max_v, arr):
- '''Input list will change'''
- i = len(arr) - 1
- while i >= 0:
- if min_v <= arr[i] <= max_v:
- del arr[i]
- arr.append(0)
- i -= 1
- return arr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement