Skip to content

Commit 3a4e802

Browse files
authored
Create 476_Number_Complement.py
1 parent f6dbc61 commit 3a4e802

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
def solution(num):
2+
num_bin = bin(num)[2:]
3+
str_bin = str(num_bin)
4+
return int(str_bin.replace('1','x').replace('0','1').replace('x','0'),2)
5+
6+
7+
8+
print(solution(1))

0 commit comments

Comments
 (0)