Last active
May 11, 2022 12:47
-
-
Save BronzeCrab/7c4205552b0da45afe5a88053ee4ba6f to your computer and use it in GitHub Desktop.
Task1, and Tak2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def task1(alist1, alist2): | |
"""Временная сложность o(len(alist1)) если len(alist1)>len(alist2)""" | |
aset = set(alist2) | |
out = [x for x in alist1 if x not in aset] | |
return out | |
assert(task1([], [])) == [] | |
assert(task1([1, 2, 3], [2, 4, 5])) == [1, 3] | |
assert(task1([1, 2, 3], [4, 5])) == [1, 2, 3] | |
assert(task1([1, 2, 3], [1, 2])) == [3] | |
def task2(alist): | |
import sys | |
out = (x for x in alist if x != 0) | |
print(sys.getsizeof(out)) | |
return out | |
for x in task2([1,2,3]): | |
print(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment