Skip to main content
3 of 5
destroyed explanation, rewrote entire code
Rhaixer
  • 2.5k
  • 13
  • 36

Python, 44 39 65 bytes

m should be a binary string, while n an int.

Had to add 26 bytes all because mathcat didn't say that 0's had to be prefixed to the parity bits.

def p(m,n):x=bin(m.count('1')%2**n)[2:];return m+"0"*(n-len(x))+x 
Rhaixer
  • 2.5k
  • 13
  • 36