fork(1) download
  1. ############# L R C ###################
  2.  
  3. def print_function(a):
  4. for i in range(0, len(a)):
  5. print(a[i])
  6.  
  7. def binary(foo):
  8. a = ""
  9. b = ""
  10. while (foo):
  11. if(foo % 2):
  12. b += '1'
  13. else:
  14. b += '0'
  15. foo = foo // 2
  16. #print(foo)
  17.  
  18. for i in range(0, 8-len(b)):
  19. a += '0'
  20.  
  21. #print(a, b)
  22. b[::-1]
  23. a += b
  24. return a
  25.  
  26. def LRC(msg):
  27.  
  28. print(msg)
  29.  
  30. n = len(msg)
  31. a = []
  32. #s = ""
  33. ans = ""
  34. print('Give the letters:')
  35. for i in range(n):
  36. s = []
  37. #s = raw_input().split()
  38. foo = ord(msg[i])
  39.  
  40. #print(foo)
  41. s.append(binary(foo));
  42. #print(s)
  43. a.append(s)
  44. #print('fff')
  45.  
  46. #print(n, " N")
  47. print_function(a)
  48. for i in range(8):
  49. one=0
  50. #print('g')
  51. for j in range(n):
  52. s = a[j][0]
  53.  
  54. #print(s)
  55.  
  56. if s[i]=='1':
  57. one+=1
  58. if one%2==1:
  59. ans+='1'
  60. else:
  61. ans+='0'
  62. print(ans)
  63.  
  64. ############### V R C #####################
  65. def VRC(msg):
  66. for i in range(0, len(msg)):
  67. #_binary = binary(ord(msg[i])
  68. #one = _binary.count('1')
  69. #print(_binary, "bujcho")
  70. TEMP = ord(msg[i])
  71. _binary = binary(TEMP)
  72. print(_binary)
  73. one = _binary.count('1')
  74. print(one)
  75. ###################################################
  76.  
  77.  
  78. def main():
  79. print('Give the message :')
  80. msg = input()
  81.  
  82. VRC(msg)
  83. LRC(msg)
  84.  
  85. #f = open("1.txt", "r")
  86. main()
  87.  
Success #stdin #stdout 0.01s 27696KB
stdin
fuck
stdout
Give the message :
00110011
4
01010111
5
01100011
4
01101011
5
fuck
Give the letters:
['00110011']
['01010111']
['01100011']
['01101011']
01101100