mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-18 05:33:54 +01:00
MISC: Hamming Code Contract description clarification (#1244)
Rewording of the Hamming code contract wording based on suggestion at discord. There's further scope on other contracts to clean up inconsistencies in example formatting.
This commit is contained in:
parent
e23db93c8b
commit
519b4fef44
@ -1297,19 +1297,22 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
|
||||
difficulty: 5,
|
||||
desc: (n: unknown): string => {
|
||||
return [
|
||||
"You are given the following decimal Value: \n",
|
||||
`${n} \n`,
|
||||
"Convert it to a binary representation and encode it as an 'extended Hamming code'. Eg:\n ",
|
||||
"Value 8 is expressed in binary as '1000', which will be encoded",
|
||||
"with the pattern 'pppdpddd', where p is a parity bit and d a data bit. The encoding of\n",
|
||||
"8 is 11110000. As another example, '10101' (Value 21) will result into (pppdpdddpd) '1001101011'.\n",
|
||||
"The answer should be given as a string containing only 1s and 0s.\n",
|
||||
"NOTE: the endianness of the data bits is reversed in relation to the endianness of the parity bits.\n",
|
||||
"NOTE: The bit at index zero is the overall parity bit, this should be set last.\n",
|
||||
"NOTE 2: You should watch the Hamming Code video from 3Blue1Brown, which explains the 'rule' of encoding,",
|
||||
"including the first index parity bit mentioned in the previous note.\n\n",
|
||||
"Extra rule for encoding:\n",
|
||||
"There should be no leading zeros in the 'data bit' section",
|
||||
"You are given the following decimal value: \n",
|
||||
`${n} \n\n`,
|
||||
"Convert it to a binary representation and encode it as an 'extended Hamming code'.\n ",
|
||||
"The number should be converted to a string of '0' and '1' with no leading zeroes.\n",
|
||||
"Parity bits are inserted at positions 0 and 2^N.\n",
|
||||
"Parity bits are used to make the total number of '1' bits in a given set of data even.\n",
|
||||
"The parity bit at position 0 considers all bits including parity bits.\n",
|
||||
"Each parity bit at position 2^N alternately considers N bits then ignores N bits, starting at position 2^N.\n",
|
||||
"The endianness of the parity bits is reversed compared to the endianness of the data bits:\n",
|
||||
"Data bits are encoded most significant bit first and the parity bits encoded least significant bit first.\n",
|
||||
"The parity bit at position 0 is set last.\n\n",
|
||||
"Examples:\n",
|
||||
"8 in binary is 1000, and encodes to 11110000 (pppdpddd - where p is a parity bit and d is a data bit)\n",
|
||||
"21 in binary is 10101, and encodes to 1001101011 (pppdpdddpd)\n\n",
|
||||
"For more information on the 'rule' of encoding, refer to Wikipedia (https://wikipedia.org/wiki/Hamming_code)",
|
||||
"or the 3Blue1Brown videos on Hamming Codes. (https://youtube.com/watch?v=X8jsijhllIA)",
|
||||
].join(" ");
|
||||
},
|
||||
gen: (): number => {
|
||||
@ -1328,15 +1331,22 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
|
||||
return [
|
||||
"You are given the following encoded binary string: \n",
|
||||
`'${n}' \n\n`,
|
||||
"Treat it as an extended Hamming code with 1 'possible' error at a random index.\n",
|
||||
"Find the 'possible' wrong bit, fix it and extract the decimal value, which is hidden inside the string.\n\n",
|
||||
"Note: The length of the binary string is dynamic, but its encoding/decoding follows Hamming's 'rule'\n",
|
||||
"Note 2: Index 0 is an 'overall' parity bit. Watch the Hamming code video from 3Blue1Brown for more information\n",
|
||||
"Note 3: There's a ~55% chance for an altered Bit. So... MAYBE there is an altered Bit 😉\n",
|
||||
"Note: The endianness of the encoded decimal value is reversed in relation to the endianness of the Hamming code. Where",
|
||||
"the Hamming code is expressed as little-endian (LSB at index 0), the decimal value encoded in it is expressed as big-endian",
|
||||
"(MSB at index 0).\n",
|
||||
"Extra note for automation: return the decimal value as a string",
|
||||
"Decode it as an 'extended Hamming code' and convert it to a decimal value.\n",
|
||||
"Parity bits are inserted at positions 0 and 2^N.\n",
|
||||
"Parity bits are used to make the total number of '1' bits in a given set of data even.\n",
|
||||
"The parity bit at position 0 considers all bits including parity bits.\n",
|
||||
"Each parity bit at position 2^N alternately considers N bits then ignores N bits, starting at position 2^N.\n",
|
||||
"The endianness of the parity bits is reversed compared to the endianness of the data bits:\n",
|
||||
"Data bits are encoded most significant bit first and the parity bits encoded least significant bit first.\n",
|
||||
"The parity bit at position 0 is set last.\n",
|
||||
"There is a ~55% chance for an altered bit at a random index.\n",
|
||||
"Find the possible altered bit, fix it and extract the decimal value.\n\n",
|
||||
"Examples:\n",
|
||||
"'11110000' passes the parity checks and has data bits of 1000, which is 8 in binary.\n",
|
||||
"'1001101010' fails the parity checks and needs the last bit to be corrected to get '1001101011',",
|
||||
"after which the data bits are found to be 10101, which is 21 in binary.\n\n",
|
||||
"For more information on the 'rule' of encoding, refer to Wikipedia (https://wikipedia.org/wiki/Hamming_code)",
|
||||
"or the 3Blue1Brown videos on Hamming Codes. (https://youtube.com/watch?v=X8jsijhllIA)",
|
||||
].join(" ");
|
||||
},
|
||||
gen: (): string => {
|
||||
|
Loading…
Reference in New Issue
Block a user