5
5
6
6
"""
7
7
* 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,
9
9
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
15
15
and minimum distance of three.
16
16
17
17
* the implemented code consists of:
18
18
* a function responsible for encoding the message (emitterConverter)
19
19
* return the encoded message
20
20
* a function responsible for decoding the message (receptorConverter)
21
21
* return the decoded message and a ack of data integrity
22
-
22
+
23
23
* 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)
25
25
you want to include in the message.
26
26
it is desired (for test purposes) to select a bit to be set
27
27
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
29
29
encoded (text).
30
-
30
+
31
31
* how this work:
32
32
declaration of variables (sizePari, be, text)
33
33
@@ -71,7 +71,7 @@ def emitterConverter(sizePar, data):
71
71
"""
72
72
:param sizePar: how many parity bits the message must have
73
73
:param data: information bits
74
- :return: message to be transmitted by unreliable medium
74
+ :return: message to be transmitted by unreliable medium
75
75
- bits of information merged with parity bits
76
76
77
77
>>> emitterConverter(4, "101010111111")
@@ -84,7 +84,6 @@ def emitterConverter(sizePar, data):
84
84
dataOut = []
85
85
parity = []
86
86
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 )]
88
87
89
88
# sorted information data for the size of the output data
90
89
dataOrd = []
@@ -188,7 +187,6 @@ def receptorConverter(sizePar, data):
188
187
dataOut = []
189
188
parity = []
190
189
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 )]
192
190
193
191
# sorted information data for the size of the output data
194
192
dataOrd = []
0 commit comments