Advertisement
Guest User

CodeBlog Task #31

a guest
Feb 21st, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. def doImmutableFilter(min_v, max_v, arr):
  3.     '''Input list doesn't changes'''
  4.     filtered_arr = list(filter(lambda x: not (min_v <= x <= max_v), arr))
  5.     return filtered_arr + [0] * (len(arr) - len(filtered_arr))
  6.  
  7.  
  8. def doMutableFilter(min_v, max_v, arr):
  9.     '''Input list will change'''
  10.     i = len(arr) - 1
  11.     while i >= 0:
  12.         if min_v <= arr[i] <= max_v:
  13.             del arr[i]
  14.             arr.append(0)
  15.         i -= 1
  16.     return arr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement