We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 88319c3 commit ff1f532Copy full SHA for ff1f532
a_b_problem.py
@@ -0,0 +1,18 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+class Solution:
4
+ """
5
+ @param a: The first integer
6
+ @param b: The second integer
7
+ @return: The sum of a and b
8
9
+ def aplusb(self, a, b):
10
+ # write your code here, try to do it without arithmetic operators.
11
+ import ctypes
12
+ a = ctypes.c_int32(a).value
13
+ b = ctypes.c_int32(b).value
14
+ while b != 0:
15
+ carry = ctypes.c_int32(a & b).value
16
+ a = ctypes.c_int32(a ^ b).value
17
+ b = ctypes.c_int32(carry << 1).value
18
+ return a
0 commit comments