55
66"""
77 * This code implement the Hamming code:
8- https://en.wikipedia.org/wiki/Hamming_code - In telecommunication,
8+ https://en.wikipedia.org/wiki/Hamming_code - In telecommunication,
99 Hamming codes are a family of linear error-correcting codes. Hamming
10- codes can detect up to two-bit errors or correct one-bit errors
11- without detection of uncorrected errors. By contrast, the simple
12- parity code cannot correct errors, and can detect only an odd number
13- of bits in error. Hamming codes are perfect codes, that is, they
14- achieve the highest possible rate for codes with their block length
10+ codes can detect up to two-bit errors or correct one-bit errors
11+ without detection of uncorrected errors. By contrast, the simple
12+ parity code cannot correct errors, and can detect only an odd number
13+ of bits in error. Hamming codes are perfect codes, that is, they
14+ achieve the highest possible rate for codes with their block length
1515 and minimum distance of three.
1616
1717 * the implemented code consists of:
1818 * a function responsible for encoding the message (emitterConverter)
1919 * return the encoded message
2020 * a function responsible for decoding the message (receptorConverter)
2121 * return the decoded message and a ack of data integrity
22-
22+
2323 * how to use:
24- to be used you must declare how many parity bits (sizePari)
24+ to be used you must declare how many parity bits (sizePari)
2525 you want to include in the message.
2626 it is desired (for test purposes) to select a bit to be set
2727 as an error. This serves to check whether the code is working correctly.
28- Lastly, the variable of the message/word that must be desired to be
28+ Lastly, the variable of the message/word that must be desired to be
2929 encoded (text).
30-
30+
3131 * how this work:
3232 declaration of variables (sizePari, be, text)
3333
@@ -71,7 +71,7 @@ def emitterConverter(sizePar, data):
7171 """
7272 :param sizePar: how many parity bits the message must have
7373 :param data: information bits
74- :return: message to be transmitted by unreliable medium
74+ :return: message to be transmitted by unreliable medium
7575 - bits of information merged with parity bits
7676
7777 >>> emitterConverter(4, "101010111111")
@@ -84,7 +84,6 @@ def emitterConverter(sizePar, data):
8484 dataOut = []
8585 parity = []
8686 binPos = [bin (x )[2 :] for x in range (1 , sizePar + len (data ) + 1 )]
87- pos = [x for x in range (1 , sizePar + len (data ) + 1 )]
8887
8988 # sorted information data for the size of the output data
9089 dataOrd = []
@@ -188,7 +187,6 @@ def receptorConverter(sizePar, data):
188187 dataOut = []
189188 parity = []
190189 binPos = [bin (x )[2 :] for x in range (1 , sizePar + len (dataOutput ) + 1 )]
191- pos = [x for x in range (1 , sizePar + len (dataOutput ) + 1 )]
192190
193191 # sorted information data for the size of the output data
194192 dataOrd = []
0 commit comments