Почернина Ольга, 528 группа CopyPaste 2768 | Молотилов Никита, 525 CopyPaste 1627 | ||||
---|---|---|---|---|---|
f | 1 | import ast | f | 1 | import ast |
2 | 2 | ||||
3 | def copypaste(one, two): | 3 | def copypaste(one, two): | ||
4 | try: | 4 | try: | ||
5 | tree1 = ast.parse(one) | 5 | tree1 = ast.parse(one) | ||
6 | tree2 = ast.parse(two) | 6 | tree2 = ast.parse(two) | ||
n | 7 | except: | n | 7 | except SyntaxError: |
8 | return False | 8 | return False | ||
t | 9 | for a, b in zip(ast.walk(tree1), ast.walk(tree2)): | t | 9 | for node1, node2 in zip(ast.walk(tree1), ast.walk(tree2)): |
10 | if type(a) != type(b): | 10 | if type(node1) != type(node2): | ||
11 | return False | 11 | return False | ||
12 | return True | 12 | return True |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|