We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a86f247 commit 2ad9510Copy full SHA for 2ad9510
elements-of-programming-interviews/problem_mapping.js
@@ -80,7 +80,7 @@ problem_mapping = {
80
"total": 10006
81
},
82
"Python: primitive_multiply.py": {
83
- "passed": 0,
+ "passed": 10006,
84
85
}
86
elements-of-programming-interviews/python/primitive_multiply.py
@@ -1,9 +1,25 @@
1
from test_framework import generic_test
2
3
4
+def add(x: int, y: int) -> int:
5
+ val = x ^ y
6
+ carry = (x & y) << 1
7
+ while carry:
8
+ x = val
9
+ y = carry
10
11
12
+ return val
13
+
14
15
def multiply(x: int, y: int) -> int:
- # TODO - you fill in here.
- return 0
16
+ product = 0
17
+ while y:
18
+ if (y & 1):
19
+ product += x
20
+ x <<= 1
21
+ y >>= 1
22
+ return product
23
24
25
if __name__ == '__main__':
0 commit comments