mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-22 16:31:15 -04:00
👾
This commit is contained in:
parent
1d44d182e2
commit
a85ed914d3
320 changed files with 0 additions and 0 deletions
|
@ -1,22 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# author: bt3gl
|
||||
|
||||
|
||||
def get_sum(self, a: int, b: int) -> int:
|
||||
|
||||
if a == -b:
|
||||
return 0
|
||||
|
||||
if abs(a) > abs(b):
|
||||
a, b = b, a
|
||||
|
||||
if a < 0:
|
||||
return - get_sum(-a, -b)
|
||||
|
||||
while b:
|
||||
|
||||
c = a & b
|
||||
a, b = a ^ b, c << 1
|
||||
|
||||
return a
|
Loading…
Add table
Add a link
Reference in a new issue