Last active
August 29, 2015 13:56
-
-
Save theredpea/9333133 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from util import groupBy | |
_4b5bmap = {'11110':'0000', | |
'01001':'0001', | |
'11100':'1110', | |
'11101':'1111'} | |
#"are pre-determined in a dictionary and they are chosen to ensure that there will be at least two transitions per block of bits." | |
#TODO: Get the whole map from http://www.mathworks.com/matlabcentral/fileexchange/27566-4b5b-encoder-line-codificador-de-linea-4b5b/ ? | |
def translate4b5b(bits): | |
return [_4b5bmap.get(_5) for _5 in groupBy(bits,5)] | |
print(''.join(translate4b5b('1110011110'))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment