0% found this document useful (0 votes)
1 views2 pages

Check Sum

Uploaded by

mehulamish2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views2 pages

Check Sum

Uploaded by

mehulamish2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

#sender

code="11001010101001010101111001110101"
d1=code[:16]
d2=code[16:]

#recv
code2="11001010101001010101111001110101"
d3=code2[:16]
d4=code2[16:]

def bsum(str1,str2):
carry="0"
final=""
for i in range(len(str1)-1,-1,-1):
final=final[::-1]
if(str1[i]=='0' and str2[i]=='0' and carry=='0'):
final+="0"
carry="0"

elif(str1[i]=='0' and str2[i]=='0' and carry=='1'):


final+="1"
carry="0"

elif(str1[i]=='0' and str2[i]=='1' and carry=='0'):


final+="1"
carry="0"

elif(str1[i]=='1' and str2[i]=='0' and carry=='0'):


final+="1"
carry="0"

elif(str1[i]=='0' and str2[i]=='1' and carry=='1'):


final+="0"
carry="1"

elif(str1[i]=='1' and str2[i]=='0' and carry=='1'):


final+="0"
carry="1"

elif(str1[i]=='1' and str2[i]=='1' and carry=='0'):


final+="0"
carry="1"

elif(str1[i]=='1' and str2[i]=='1' and carry=='1'):


final+="1"
carry="1"
else:
final=final[::-1]
break
final=final[::-1]
return(final)
s1=bsum(d1,d2)
s1_new=""
for i in range(0,len(s1)):
if(s1[i]=="1"):
s1_new+="0"
else:
s1_new+="1"
s2=bsum(d3,d4)

print("Check Sum = ",bsum(s1_new, s2))

You might also like