Skip to main content
4 of 5
added 34 characters in body
Rhaixer
  • 2.5k
  • 13
  • 36

Python, 44 39 65 40 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, but doesn't matter since Neil found a shorter solution.

lambda m,n:m+bin(m.count('1')+2**n)[-n:] 
Rhaixer
  • 2.5k
  • 13
  • 36