Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CONTRACT: Clarify applicibility of wiki entry in Hamming contracts. #1637

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/data/codingcontracttypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1295,18 +1295,20 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
`${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",
"A parity bit is inserted at position 0 and at every position N where N is a power of 2.\n",
"An 'extended Hamming code' has an additional parity bit to enhance error detection.\n",
"A parity bit is inserted at every position N where N is a power of 2, with the additional parity bit at position 0.\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 additional parity bit at position 0 considers all bits including parity bits.\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",
"The additional parity bit at position 0 is set last.\n\n",
"Examples:\n\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)",
"or the 3Blue1Brown videos on Hamming Codes. (https://youtube.com/watch?v=X8jsijhllIA)\n",
"NOTE: The wikipedia entry does not cover the specific 'extended Hamming code' structure used in this contract.",
].join(" ");
},
gen: (): number => {
Expand All @@ -1329,21 +1331,23 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
`'${n}' \n\n`,
"Decode it as an 'extended Hamming code' and convert it to a decimal value.\n",
"The binary string may include leading zeroes.\n",
"A parity bit is inserted at position 0 and at every position N where N is a power of 2.\n",
"An 'extended Hamming code' has an additional parity bit to enhance error detection.\n",
"A parity bit is inserted at every position N where N is a power of 2, with the additional parity bit at position 0.\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 2^N bits then ignores 2^N bits, starting at position 2^N.\n",
"The additional parity bit at position 0 considers all bits including parity bits.\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",
"The additional 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\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)",
"or the 3Blue1Brown videos on Hamming Codes. (https://youtube.com/watch?v=X8jsijhllIA)\n",
"NOTE: The wikipedia entry does not cover the specific 'extended Hamming code' structure used in this contract.",
].join(" ");
},
gen: (): string => {
Expand Down