Last active
March 24, 2024 09:25
-
-
Save Attumm/5ae823a5d4559a14e153d17cc826806b to your computer and use it in GitHub Desktop.
This file contains 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
71 0 RESUME 0 | |
72 2 LOAD_GLOBAL 1 (NULL + len) | |
12 LOAD_FAST 0 (nums) | |
14 CALL 1 | |
22 STORE_FAST 1 (n) | |
73 24 BUILD_LIST 0 | |
26 STORE_FAST 2 (result) | |
74 28 LOAD_CONST 1 ((1, 1)) | |
30 UNPACK_SEQUENCE 2 | |
34 STORE_FAST 3 (prefix) | |
36 STORE_FAST 4 (postfix) | |
75 38 LOAD_GLOBAL 3 (NULL + range) | |
48 LOAD_FAST 1 (n) | |
50 CALL 1 | |
58 GET_ITER | |
>> 60 FOR_ITER 27 (to 118) | |
64 STORE_FAST 5 (i) | |
76 66 LOAD_FAST 2 (result) | |
68 LOAD_ATTR 5 (NULL|self + append) | |
88 LOAD_FAST 3 (prefix) | |
90 CALL 1 | |
98 POP_TOP | |
77 100 LOAD_FAST 3 (prefix) | |
102 LOAD_FAST 0 (nums) | |
104 LOAD_FAST 5 (i) | |
106 BINARY_SUBSCR | |
110 BINARY_OP 18 (*=) | |
114 STORE_FAST 3 (prefix) | |
116 JUMP_BACKWARD 29 (to 60) | |
75 >> 118 END_FOR | |
79 120 LOAD_GLOBAL 3 (NULL + range) | |
130 LOAD_FAST 1 (n) | |
132 LOAD_CONST 2 (1) | |
134 BINARY_OP 10 (-) | |
138 LOAD_CONST 3 (-1) | |
140 LOAD_CONST 3 (-1) | |
142 CALL 3 | |
150 GET_ITER | |
>> 152 FOR_ITER 23 (to 202) | |
156 STORE_FAST 5 (i) | |
80 158 LOAD_FAST 2 (result) | |
160 LOAD_FAST 5 (i) | |
162 COPY 2 | |
164 COPY 2 | |
166 BINARY_SUBSCR | |
170 LOAD_FAST 4 (postfix) | |
172 BINARY_OP 18 (*=) | |
176 SWAP 3 | |
178 SWAP 2 | |
180 STORE_SUBSCR | |
81 184 LOAD_FAST 4 (postfix) | |
186 LOAD_FAST 0 (nums) | |
188 LOAD_FAST 5 (i) | |
190 BINARY_SUBSCR | |
194 BINARY_OP 18 (*=) | |
198 STORE_FAST 4 (postfix) | |
200 JUMP_BACKWARD 25 (to 152) | |
79 >> 202 END_FOR | |
83 204 LOAD_FAST 2 (result) | |
206 RETURN_VALUE |
This file contains 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
87 0 RESUME 0 | |
88 2 LOAD_GLOBAL 1 (NULL + len) | |
12 LOAD_FAST 0 (nums) | |
14 CALL 1 | |
22 STORE_FAST 1 (n) | |
89 24 LOAD_CONST 0 (None) | |
26 BUILD_LIST 1 | |
28 LOAD_FAST 1 (n) | |
30 BINARY_OP 5 (*) | |
34 STORE_FAST 2 (result) | |
90 36 LOAD_CONST 1 ((1, 1)) | |
38 UNPACK_SEQUENCE 2 | |
42 STORE_FAST 3 (prefix) | |
44 STORE_FAST 4 (postfix) | |
91 46 LOAD_GLOBAL 3 (NULL + range) | |
56 LOAD_FAST 1 (n) | |
58 CALL 1 | |
66 GET_ITER | |
>> 68 FOR_ITER 15 (to 102) | |
72 STORE_FAST 5 (i) | |
92 74 LOAD_FAST 3 (prefix) | |
76 LOAD_FAST 2 (result) | |
78 LOAD_FAST 5 (i) | |
80 STORE_SUBSCR | |
93 84 LOAD_FAST 3 (prefix) | |
86 LOAD_FAST 0 (nums) | |
88 LOAD_FAST 5 (i) | |
90 BINARY_SUBSCR | |
94 BINARY_OP 18 (*=) | |
98 STORE_FAST 3 (prefix) | |
100 JUMP_BACKWARD 17 (to 68) | |
91 >> 102 END_FOR | |
95 104 LOAD_GLOBAL 3 (NULL + range) | |
114 LOAD_FAST 1 (n) | |
116 LOAD_CONST 2 (1) | |
118 BINARY_OP 10 (-) | |
122 LOAD_CONST 3 (-1) | |
124 LOAD_CONST 3 (-1) | |
126 CALL 3 | |
134 GET_ITER | |
>> 136 FOR_ITER 23 (to 186) | |
140 STORE_FAST 5 (i) | |
96 142 LOAD_FAST 2 (result) | |
144 LOAD_FAST 5 (i) | |
146 COPY 2 | |
148 COPY 2 | |
150 BINARY_SUBSCR | |
154 LOAD_FAST 4 (postfix) | |
156 BINARY_OP 18 (*=) | |
160 SWAP 3 | |
162 SWAP 2 | |
164 STORE_SUBSCR | |
97 168 LOAD_FAST 4 (postfix) | |
170 LOAD_FAST 0 (nums) | |
172 LOAD_FAST 5 (i) | |
174 BINARY_SUBSCR | |
178 BINARY_OP 18 (*=) | |
182 STORE_FAST 4 (postfix) | |
184 JUMP_BACKWARD 25 (to 136) | |
95 >> 186 END_FOR | |
99 188 LOAD_FAST 2 (result) | |
190 RETURN_VALUE |
This file contains 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 product_except_self_append(nums): | |
n = len(nums) | |
result = [] | |
prefix, postfix = 1, 1 | |
for i in range(n): | |
result.append(prefix) | |
prefix *= nums[i] | |
for i in range(n-1, -1, -1): | |
result[i] *= postfix | |
postfix *= nums[i] | |
return result | |
def product_except_self_index(nums): | |
n = len(nums) | |
result = [None] * n | |
prefix, postfix = 1, 1 | |
for i in range(n): | |
result[i] = prefix | |
prefix *= nums[i] | |
for i in range(n-1, -1, -1): | |
result[i] *= postfix | |
postfix *= nums[i] | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment