-
Notifications
You must be signed in to change notification settings - Fork 0
/
com.py
42 lines (41 loc) · 835 Bytes
/
com.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def convert_to_binary(a):
ret=[]
while a>0:
rem=int(a%2)
ret.append(str(rem))
a=int(a/2)
s= ''.join(ret)
s=s[::-1]
return int(s)
def diff(A):
for i in range(len(A)):
A[i]=convert_to_binary(A[i])
temp=[]
for i in range(len(A)):
for j in range(i+1,len(A)):
temp.append((A[i],A[j]))
print(A)
print(temp)
# def result(a,b):
# x=[int(m) for m in str(a)]
# y=[int(n) for n in str(b)]
# res=0
# for i in range(max(len(x),len(y))):
# return res
def result(a,b):
x=bin(a)
y=bin(b)
s=0
for i in range(len(x)-1,0-1):
if x[i] is not y[i]:
s+=1
return s
diff([2,3,4,7])
# print(result(4,7))
# print(result(10,11))
a=[1,1]
b=[1,0,0]
s=0
for i,j in zip(a,b):
print(i,j)
print(bin(3,4))