From 28ea0f02d8783e0104bac6825a835cc5e57f7e7c Mon Sep 17 00:00:00 2001 From: Kah Goh Date: Sat, 8 Mar 2025 06:59:56 +0800 Subject: [PATCH 01/12] Add intergalactic-transmission exercise --- .../canonical-data.json | 440 ++++++++++++++++++ .../instructions.md | 37 ++ .../introduction.md | 22 + .../intergalactic-transmission/metadata.toml | 4 + 4 files changed, 503 insertions(+) create mode 100644 exercises/intergalactic-transmission/canonical-data.json create mode 100644 exercises/intergalactic-transmission/instructions.md create mode 100644 exercises/intergalactic-transmission/introduction.md create mode 100644 exercises/intergalactic-transmission/metadata.toml diff --git a/exercises/intergalactic-transmission/canonical-data.json b/exercises/intergalactic-transmission/canonical-data.json new file mode 100644 index 0000000000..f0970d14a8 --- /dev/null +++ b/exercises/intergalactic-transmission/canonical-data.json @@ -0,0 +1,440 @@ +{ + "exercise": "intergalactic-transmission", + "comments": ["Inputs and expected data are given in hexadecimal"], + "cases": [ + { + "description": "calculate transmit sequences", + "cases": [ + { + "uuid": "0d570e11-16a6-4dc7-8dc6-bad417ecb81", + "description": "empty message", + "property": "transmitSequence", + "input": { + "message": [] + }, + "expected": [] + }, + { + "uuid": "ee27ea2d-8999-4f23-9275-8f6879545f86", + "description": "0x00 is transmitted as 0x0000", + "property": "transmitSequence", + "input": { + "message": ["0x00"] + }, + "expected": ["0x00", "0x00"] + }, + { + "uuid": "97f27f98-8020-402d-be85-f21ba54a6df0", + "description": "0x02 is transmitted as 0x0100", + "property": "transmitSequence", + "input": { + "message": ["0x02"] + }, + "expected": ["0x01", "0x00"] + }, + { + "uuid": "24712fb9-0336-4e2f-835e-d2350f29c420", + "description": "0x06 is transmitted as 0x0600", + "property": "transmitSequence", + "input": { + "message": ["0x06"] + }, + "expected": ["0x06", "0x00"] + }, + { + "uuid": "7630b5a9-dba1-4178-b2a0-4a376f7414e0", + "description": "0x05 is transmitted as 0x0581", + "property": "transmitSequence", + "input": { + "message": ["0x05"] + }, + "expected": ["0x05", "0x81"] + }, + { + "uuid": "ab4fe80b-ef8e-4a99-b4fb-001937af415d", + "description": "0x29 is transmitted as 0x2881", + "property": "transmitSequence", + "input": { + "message": ["0x29"] + }, + "expected": ["0x28", "0x81"] + }, + { + "uuid": "4e200d84-593b-4449-b7c0-4de1b6a0955e", + "description": "0xc001c0de is transmitted as 0xc000711be1", + "property": "transmitSequence", + "input": { + "message": ["0xc0", "0x01", "0xc0", "0xde"] + }, + "expected": ["0xc0", "0x00", "0x71", "0x1b", "0xe1"] + }, + { + "uuid": "fbc537e9-6b21-4f4a-8c2b-9cf9b702a9b7", + "description": "six byte message", + "property": "transmitSequence", + "input": { + "message": ["0x47", "0x72", "0x65", "0x61", "0x74", "0x21"] + }, + "expected": ["0x47", "0xb8", "0x99", "0xac", "0x17", "0xa0", "0x84"] + }, + { + "uuid": "d5b75adf-b5fc-4f77-b4ab-77653e30f07c", + "description": "seven byte message", + "comments": ["at 7 bytes long, no padding is required"], + "property": "transmitSequence", + "input": { + "message": ["0x47", "0x72", "0x65", "0x61", "0x74", "0x31", "0x21"] + }, + "expected": [ + "0x47", + "0xb8", + "0x99", + "0xac", + "0x17", + "0xa0", + "0xc5", + "0x42" + ] + }, + { + "uuid": "6d8b297b-da1d-435e-bcd7-55fbb1400e73", + "description": "eight byte message", + "property": "transmitSequence", + "input": { + "message": [ + "0xc0", + "0x01", + "0x13", + "0x37", + "0xc0", + "0xde", + "0x21", + "0x21" + ] + }, + "expected": [ + "0xc0", + "0x00", + "0x44", + "0x66", + "0x7d", + "0x06", + "0x78", + "0x42", + "0x21", + "0x81" + ] + }, + { + "uuid": "54a0642a-d5aa-490c-be89-8e171a0cab6f", + "description": "twenty byte message", + "property": "transmitSequence", + "input": { + "message": [ + "0x45", + "0x78", + "0x65", + "0x72", + "0x63", + "0x69", + "0x73", + "0x6d", + "0x20", + "0x69", + "0x73", + "0x20", + "0x61", + "0x77", + "0x65", + "0x73", + "0x6f", + "0x6d", + "0x65", + "0x21" + ] + }, + "expected": [ + "0x44", + "0xbd", + "0x18", + "0xaf", + "0x27", + "0x1b", + "0xa5", + "0xe7", + "0x6c", + "0x90", + "0x1b", + "0x2e", + "0x33", + "0x03", + "0x84", + "0xee", + "0x65", + "0xb8", + "0xdb", + "0xed", + "0xd7", + "0x28", + "0x84" + ] + } + ] + }, + { + "description": "decode received messages", + "cases": [ + { + "uuid": "9a8084dd-3336-474c-90cb-8a852524604d", + "description": "empty message", + "property": "decodeMessage", + "input": { + "message": [] + }, + "expected": [] + }, + { + "uuid": "879af739-0094-4736-9127-bd441b1ddbbf", + "description": "zero message", + "property": "decodeMessage", + "input": { + "message": ["0x00", "0x00"] + }, + "expected": ["0x00"] + }, + { + "uuid": "7a89eeef-96c5-4329-a246-ec181a8e959a", + "description": "0x0300 is decoded to 0x02", + "property": "decodeMessage", + "input": { + "message": ["0x03", "0x00"] + }, + "expected": ["0x02"] + }, + { + "uuid": "3e515af7-8b62-417f-960c-3454bca7f806", + "description": "0x0581 is decoded to 0x05", + "property": "decodeMessage", + "input": { + "message": ["0x05", "0x81"] + }, + "expected": ["0x05"] + }, + { + "uuid": "a1b4a3f7-9f05-4b7a-b86e-d7c6fc3f16a9", + "description": "0x2881 is decoded to 0x29", + "property": "decodeMessage", + "input": { + "message": ["0x28", "0x81"] + }, + "expected": ["0x29"] + }, + { + "uuid": "2e99d617-4c91-4ad5-9217-e4b2447d6e4a", + "description": "first byte has wrong parity", + "property": "decodeMessage", + "input": { + "message": ["0x07", "0x00"] + }, + "expected": { + "error": "wrong parity" + } + }, + { + "uuid": "507e212d-3dae-42e8-88b4-2223838ff8d2", + "description": "second byte has wrong parity", + "property": "decodeMessage", + "input": { + "message": ["0x03", "0x68"] + }, + "expected": { + "error": "wrong parity" + } + }, + { + "uuid": "b985692e-6338-46c7-8cea-bc38996d4dfd", + "description": "0xcf4b00 is decoded to 0xce94", + "property": "decodeMessage", + "input": { + "message": ["0xcf", "0x4b", "0x00"] + }, + "expected": ["0xce", "0x94"] + }, + { + "uuid": "7a1f4d48-696d-4679-917c-21b7da3ff3fd", + "description": "0xe2566500 is decoded to 0xe2ad90", + "property": "decodeMessage", + "input": { + "message": ["0xe2", "0x56", "0x65", "0x00"] + }, + "expected": ["0xe2", "0xad", "0x90"] + }, + { + "uuid": "467549dc-a558-443b-80c5-ff3d4eb305d4", + "description": "six byte message", + "property": "decodeMessage", + "input": { + "message": ["0x47", "0xb8", "0x99", "0xac", "0x17", "0xa0", "0x84"] + }, + "expected": ["0x47", "0x72", "0x65", "0x61", "0x74", "0x21"] + }, + { + "uuid": "1f3be5fb-093a-4661-9951-c1c4781c71ea", + "description": "seven byte message", + "property": "decodeMessage", + "input": { + "message": [ + "0x47", + "0xb8", + "0x99", + "0xac", + "0x17", + "0xa0", + "0xc5", + "0x42" + ] + }, + "expected": ["0x47", "0x72", "0x65", "0x61", "0x74", "0x31", "0x21"] + }, + { + "uuid": "6065b8b3-9dcd-45c9-918c-b427cfdb28c1", + "description": "last byte in seven byte message has wrong parity", + "property": "decodeMessage", + "input": { + "message": [ + "0x47", + "0xb8", + "0x99", + "0xac", + "0x17", + "0xa0", + "0xc5", + "0x43" + ] + }, + "expected": { + "error": "wrong parity" + } + }, + { + "uuid": "98af97b7-9cca-4c4c-9de3-f70e227a4cb1", + "description": "eight byte message", + "property": "decodeMessage", + "input": { + "message": [ + "0xc0", + "0x00", + "0x44", + "0x66", + "0x7d", + "0x06", + "0x78", + "0x42", + "0x21", + "0x81" + ] + }, + "expected": [ + "0xc0", + "0x01", + "0x13", + "0x37", + "0xc0", + "0xde", + "0x21", + "0x21" + ] + }, + { + "uuid": "aa7d4785-2bb9-43a4-a38a-203325c464fb", + "description": "twenty byte message", + "property": "decodeMessage", + "input": { + "message": [ + "0x44", + "0xbd", + "0x18", + "0xaf", + "0x27", + "0x1b", + "0xa5", + "0xe7", + "0x6c", + "0x90", + "0x1b", + "0x2e", + "0x33", + "0x03", + "0x84", + "0xee", + "0x65", + "0xb8", + "0xdb", + "0xed", + "0xd7", + "0x28", + "0x84" + ] + }, + "expected": [ + "0x45", + "0x78", + "0x65", + "0x72", + "0x63", + "0x69", + "0x73", + "0x6d", + "0x20", + "0x69", + "0x73", + "0x20", + "0x61", + "0x77", + "0x65", + "0x73", + "0x6f", + "0x6d", + "0x65", + "0x21" + ] + }, + { + "uuid": "4c86e034-b066-42ac-8497-48f9bc1723c1", + "description": "wrong parity on 16th byte", + "property": "decodeMessage", + "input": { + "message": [ + "0x44", + "0xbd", + "0x18", + "0xaf", + "0x27", + "0x1b", + "0xa5", + "0xe7", + "0x6c", + "0x90", + "0x1b", + "0x2e", + "0x33", + "0x03", + "0x84", + "0xef", + "0x65", + "0xb8", + "0xdb", + "0xed", + "0xd7", + "0x28", + "0x84" + ] + }, + "expected": { + "error": "wrong parity" + } + } + ] + } + ] +} diff --git a/exercises/intergalactic-transmission/instructions.md b/exercises/intergalactic-transmission/instructions.md new file mode 100644 index 0000000000..354bb03016 --- /dev/null +++ b/exercises/intergalactic-transmission/instructions.md @@ -0,0 +1,37 @@ +# Instructions + +Your job is to help implement the message sequencer to add the parity bit to the messages and the decoder to receive messages. + +The entire message, itself, is sequence of a number of bytes. +The transmitters and receivers can only transmit and receive one byte at a time, so parity bit needs to be added every eighth bit. +The algorithm for adding the bits is as follows: +1. Divide the message bits into groups of 7, starting from the left (the message is transmitted from left to right). +2. If the last group has less than 7 bits, append some 0s to pad the group to 7 bits. +3. For each group, determine if there are an odd or even number of 1s. +4. If the group has even number of 1s or none at all, append a 0 to the group. Otherwise, append 1 if there is odd number. + +For example, consider the message 0xC0_01_C0_DE. +Writing this out in binary and locating every 7th bit: + +```text +C 0 0 1 C 0 D E +1100_0000 0000_0001 1100_0000 1101_1110 + ↑ ↑ ↑ ↑ (7th bits) +``` + +The last group has only 4 bits (0b1110), so three 0 bits are appended to make it 7 bits: + +```text +| 1100_000 | 0000_000 | 0111_000 | 0001_101 | 1110_000 | +``` + +The first group contains two 1s (an even number of 1s), so 0 is appended to the group. +The second group has none, so append 0. +The rest have three, so they append 1. + +```text +| 1100_0000 | 0000_0000 | 0111_0001 | 0001_1011 | 1110_0001 | +| C 0 | 0 0 | 7 1 | 1 B | E 1 | (in hex) +``` + +Thus, the transmission sequence is 0xC0_00_71_1B_E1. diff --git a/exercises/intergalactic-transmission/introduction.md b/exercises/intergalactic-transmission/introduction.md new file mode 100644 index 0000000000..caa4d6af4b --- /dev/null +++ b/exercises/intergalactic-transmission/introduction.md @@ -0,0 +1,22 @@ +# Introduction + +Trillions upon trillions of messages zip between Earth and neighboring galaxies every millisecond. +But transmitting over such long distances is tricky. +Pesky solar flares, temporal distortions, stray forces, heck even the flap of a space butterfly's wing can cause a random bit to flip in transmission. + +Now imagine the consequences: +- Crashing the Intergalactic Share Market when "buy low" turns to "sell now". +- Losing contact with the Kepler Whirl system when "save new worm hole" becomes "cave new worm hole". +- Or plunging the universe into existential horror by replacing a cowboy emoji 🀠 with a clown emoji 🀑. + +Thus, detecting corrupted messages isn’t just important β€” it’s critical. +The receiver must know when something has gone wrong before disaster strikes. + +But how? +Scientists and engineers from across the universe have been battling this problem for eons. +Entire cosmic AI superclusters churn through the data. +And then, one day, a legend resurfaces - an ancient, powerful method, whispered in debugging forums, muttered by engineers who've seen too much ... + +The Parity Bit. + +A method so simple, so powerful, that it might just save interstellar communication. diff --git a/exercises/intergalactic-transmission/metadata.toml b/exercises/intergalactic-transmission/metadata.toml new file mode 100644 index 0000000000..1611846794 --- /dev/null +++ b/exercises/intergalactic-transmission/metadata.toml @@ -0,0 +1,4 @@ +title = "Intergalactic Transmission" +blurb = "Add parity bits to a message for transmission" +source = "Kah Goh" +source_url = "" From cbfcebdb71034d4cb93495143ac45ed9525305ce Mon Sep 17 00:00:00 2001 From: Kah Goh Date: Fri, 4 Apr 2025 22:16:38 +0800 Subject: [PATCH 02/12] Revise instructions & introduction --- .../instructions.md | 57 ++++++++++++------- .../introduction.md | 9 +-- .../intergalactic-transmission/metadata.toml | 2 +- 3 files changed, 42 insertions(+), 26 deletions(-) diff --git a/exercises/intergalactic-transmission/instructions.md b/exercises/intergalactic-transmission/instructions.md index 354bb03016..1b65d47d62 100644 --- a/exercises/intergalactic-transmission/instructions.md +++ b/exercises/intergalactic-transmission/instructions.md @@ -1,37 +1,52 @@ # Instructions -Your job is to help implement the message sequencer to add the parity bit to the messages and the decoder to receive messages. +A parity bit is simple way of detecting transmission errors. +The transmitters and receives can only transmit and receive *exactly* eight bits at a time (including the parity bit). +The parity bit is set so that there is an *even* number 1s in each transmission and is always the first bit from the right. +So if the receiver receives `11000001`, `01110101` or `01000000` (i.e. a transmission with an odd number of 1 bits), it knows there is an error. -The entire message, itself, is sequence of a number of bytes. -The transmitters and receivers can only transmit and receive one byte at a time, so parity bit needs to be added every eighth bit. -The algorithm for adding the bits is as follows: -1. Divide the message bits into groups of 7, starting from the left (the message is transmitted from left to right). -2. If the last group has less than 7 bits, append some 0s to pad the group to 7 bits. -3. For each group, determine if there are an odd or even number of 1s. -4. If the group has even number of 1s or none at all, append a 0 to the group. Otherwise, append 1 if there is odd number. +However, messages are rarely this short. +The message needs to be transmitted in a sequence when they are longer. -For example, consider the message 0xC0_01_C0_DE. -Writing this out in binary and locating every 7th bit: +For example, consider the message `11000000 00000001 11000000 11011110` (or in `C0 01 C0 DE` hex). + +Since each transmission contains exactly eight bits, it can only contain seven bits of data and the parity bit. +A parity bit must then be inserted after every seven bits of data: ```text -C 0 0 1 C 0 D E -1100_0000 0000_0001 1100_0000 1101_1110 - ↑ ↑ ↑ ↑ (7th bits) +11000000 00000001 11000000 11011110 + ↑ ↑ ↑ ↑ (7th bits) ``` -The last group has only 4 bits (0b1110), so three 0 bits are appended to make it 7 bits: +So transmission sequence for this message looks like this: ```text -| 1100_000 | 0000_000 | 0111_000 | 0001_101 | 1110_000 | +1100000_ β”‚ 0000000_ β”‚ 0111000_ β”‚ 0001101_ β”‚ 1110 + ↑ ↑ ↑ ↑ (parity bit locations) ``` -The first group contains two 1s (an even number of 1s), so 0 is appended to the group. -The second group has none, so append 0. -The rest have three, so they append 1. +The data in the first transmission in the sequence (`1100000`) has two 1 bits (an even number), so the parity bit is 0. +The first transmission becomes `11000000` (or `C0` in hex). + +The data in the next transmission (`0000000`) has none (an even number again), so the parity bit is 0 again. +The second transmission becomes `00000000` (or `00` in hex). + +The data for the next two transmissions (`0111000` and `0001101`) have three 1 bits. +Their parity bits are set to 1 so that they have an even number of 1 bits in the transmission. +They are transmitted as `01110001` and `00011011` (or `71` and `1B` in hex). + +The last transmission (`1110`) has only four bits of data. +Since exactly eight bits are transmitted at a time and the parity bit is the right most bit, three 0 bits and then the parity bit is added to make up eight bits. +It now looks like this (where `_` is the parity bit): ```text -| 1100_0000 | 0000_0000 | 0111_0001 | 0001_1011 | 1110_0001 | -| C 0 | 0 0 | 7 1 | 1 B | E 1 | (in hex) +1110 000_ + ↑↑↑ (added 0 bits) ``` -Thus, the transmission sequence is 0xC0_00_71_1B_E1. +There is an odd number of 1 bits again, so the parity bit is to 1. +The last transmission in the sequence becomes `11100001` (or `E1` in hex). + +The entire transmission sequence for this message then `11000000 00000000 01110001 00011011 11100001` (or `C0 00 71 1B E1` in hex). + +Your job is to help implement the message sequencer to calculate the transmission sequence and the decoder for receiving messages. diff --git a/exercises/intergalactic-transmission/introduction.md b/exercises/intergalactic-transmission/introduction.md index caa4d6af4b..816e6ce123 100644 --- a/exercises/intergalactic-transmission/introduction.md +++ b/exercises/intergalactic-transmission/introduction.md @@ -2,21 +2,22 @@ Trillions upon trillions of messages zip between Earth and neighboring galaxies every millisecond. But transmitting over such long distances is tricky. -Pesky solar flares, temporal distortions, stray forces, heck even the flap of a space butterfly's wing can cause a random bit to flip in transmission. +Pesky solar flares, temporal distortions, stray forces, and even the flap of a space butterfly's wing can cause a random bit to change during transmission. Now imagine the consequences: + - Crashing the Intergalactic Share Market when "buy low" turns to "sell now". - Losing contact with the Kepler Whirl system when "save new worm hole" becomes "cave new worm hole". - Or plunging the universe into existential horror by replacing a cowboy emoji 🀠 with a clown emoji 🀑. -Thus, detecting corrupted messages isn’t just important β€” it’s critical. +Detecting corrupted messages isn’t just important β€” it’s critical. The receiver must know when something has gone wrong before disaster strikes. But how? Scientists and engineers from across the universe have been battling this problem for eons. Entire cosmic AI superclusters churn through the data. -And then, one day, a legend resurfaces - an ancient, powerful method, whispered in debugging forums, muttered by engineers who've seen too much ... +And then, one day, a legend resurfaces - an ancient, powerful method, whispered in debugging forums, muttered by engineers who've seen too much... -The Parity Bit. +The Parity Bit! A method so simple, so powerful, that it might just save interstellar communication. diff --git a/exercises/intergalactic-transmission/metadata.toml b/exercises/intergalactic-transmission/metadata.toml index 1611846794..278a2843d3 100644 --- a/exercises/intergalactic-transmission/metadata.toml +++ b/exercises/intergalactic-transmission/metadata.toml @@ -1,4 +1,4 @@ title = "Intergalactic Transmission" blurb = "Add parity bits to a message for transmission" source = "Kah Goh" -source_url = "" +source_url = "https://github.com/exercism/problem-specifications/pull/2543" From 5066eff7ac4ac8b94cef2cad6e562b3c24bebc03 Mon Sep 17 00:00:00 2001 From: Kah Goh Date: Fri, 4 Apr 2025 22:21:03 +0800 Subject: [PATCH 03/12] Fix formatting --- exercises/intergalactic-transmission/instructions.md | 4 ++-- exercises/intergalactic-transmission/introduction.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/exercises/intergalactic-transmission/instructions.md b/exercises/intergalactic-transmission/instructions.md index 1b65d47d62..4e91234192 100644 --- a/exercises/intergalactic-transmission/instructions.md +++ b/exercises/intergalactic-transmission/instructions.md @@ -3,9 +3,9 @@ A parity bit is simple way of detecting transmission errors. The transmitters and receives can only transmit and receive *exactly* eight bits at a time (including the parity bit). The parity bit is set so that there is an *even* number 1s in each transmission and is always the first bit from the right. -So if the receiver receives `11000001`, `01110101` or `01000000` (i.e. a transmission with an odd number of 1 bits), it knows there is an error. +So if the receiver receives `11000001`, `01110101` or `01000000` (i.e. a transmission with an odd number of 1 bits), it knows there is an error. -However, messages are rarely this short. +However, messages are rarely this short. The message needs to be transmitted in a sequence when they are longer. For example, consider the message `11000000 00000001 11000000 11011110` (or in `C0 01 C0 DE` hex). diff --git a/exercises/intergalactic-transmission/introduction.md b/exercises/intergalactic-transmission/introduction.md index 816e6ce123..d8067a00d1 100644 --- a/exercises/intergalactic-transmission/introduction.md +++ b/exercises/intergalactic-transmission/introduction.md @@ -1,6 +1,6 @@ # Introduction -Trillions upon trillions of messages zip between Earth and neighboring galaxies every millisecond. +Trillions upon trillions of messages zip between Earth and neighboring galaxies every millisecond. But transmitting over such long distances is tricky. Pesky solar flares, temporal distortions, stray forces, and even the flap of a space butterfly's wing can cause a random bit to change during transmission. @@ -10,7 +10,7 @@ Now imagine the consequences: - Losing contact with the Kepler Whirl system when "save new worm hole" becomes "cave new worm hole". - Or plunging the universe into existential horror by replacing a cowboy emoji 🀠 with a clown emoji 🀑. -Detecting corrupted messages isn’t just important β€” it’s critical. +Detecting corrupted messages isn’t just important β€” it’s critical. The receiver must know when something has gone wrong before disaster strikes. But how? From 4f7bad85f9c065a3f5be116122c3789e0a7f3e83 Mon Sep 17 00:00:00 2001 From: Kah Goh Date: Fri, 4 Apr 2025 22:26:05 +0800 Subject: [PATCH 04/12] Fix uuid --- exercises/intergalactic-transmission/canonical-data.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/intergalactic-transmission/canonical-data.json b/exercises/intergalactic-transmission/canonical-data.json index f0970d14a8..2a5457dd1a 100644 --- a/exercises/intergalactic-transmission/canonical-data.json +++ b/exercises/intergalactic-transmission/canonical-data.json @@ -6,7 +6,7 @@ "description": "calculate transmit sequences", "cases": [ { - "uuid": "0d570e11-16a6-4dc7-8dc6-bad417ecb81", + "uuid": "f99d4046-b429-4582-9324-f0bcac7ab51c", "description": "empty message", "property": "transmitSequence", "input": { From 9c3ba897c3997ec29a66e95ee7eb88669f9efb5e Mon Sep 17 00:00:00 2001 From: Kah Goh Date: Fri, 4 Apr 2025 22:28:55 +0800 Subject: [PATCH 05/12] Fix Markdown lint errors --- exercises/intergalactic-transmission/instructions.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/exercises/intergalactic-transmission/instructions.md b/exercises/intergalactic-transmission/instructions.md index 4e91234192..d6d0a2e267 100644 --- a/exercises/intergalactic-transmission/instructions.md +++ b/exercises/intergalactic-transmission/instructions.md @@ -1,9 +1,9 @@ # Instructions A parity bit is simple way of detecting transmission errors. -The transmitters and receives can only transmit and receive *exactly* eight bits at a time (including the parity bit). -The parity bit is set so that there is an *even* number 1s in each transmission and is always the first bit from the right. -So if the receiver receives `11000001`, `01110101` or `01000000` (i.e. a transmission with an odd number of 1 bits), it knows there is an error. +The transmitters and receives can only transmit and receive _exactly_ eight bits at a time (including the parity bit). +The parity bit is set so that there is an _even_ number 1s in each transmission and is always the first bit from the right. +So if the receiver receives `11000001`, `01110101` or `01000000` (i.e. a transmission with an odd number of 1 bits), it knows there is an error. However, messages are rarely this short. The message needs to be transmitted in a sequence when they are longer. @@ -29,7 +29,7 @@ The data in the first transmission in the sequence (`1100000`) has two 1 bits (a The first transmission becomes `11000000` (or `C0` in hex). The data in the next transmission (`0000000`) has none (an even number again), so the parity bit is 0 again. -The second transmission becomes `00000000` (or `00` in hex). +The second transmission becomes `00000000` (or `00` in hex). The data for the next two transmissions (`0111000` and `0001101`) have three 1 bits. Their parity bits are set to 1 so that they have an even number of 1 bits in the transmission. From b9062ca7da6584eb9e12e5e974fa9338c711e1d2 Mon Sep 17 00:00:00 2001 From: Kah Goh Date: Sun, 6 Apr 2025 21:14:52 +0800 Subject: [PATCH 06/12] Apply suggestions --- .../instructions.md | 25 +++++++++++-------- .../introduction.md | 4 +-- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/exercises/intergalactic-transmission/instructions.md b/exercises/intergalactic-transmission/instructions.md index d6d0a2e267..3d33287a3e 100644 --- a/exercises/intergalactic-transmission/instructions.md +++ b/exercises/intergalactic-transmission/instructions.md @@ -1,7 +1,9 @@ # Instructions +Your job is to help implement the message sequencer to calculate the transmission sequence and the decoder for receiving messages. + A parity bit is simple way of detecting transmission errors. -The transmitters and receives can only transmit and receive _exactly_ eight bits at a time (including the parity bit). +The transmitters and receivers can only transmit and receive _exactly_ eight bits at a time (including the parity bit). The parity bit is set so that there is an _even_ number 1s in each transmission and is always the first bit from the right. So if the receiver receives `11000001`, `01110101` or `01000000` (i.e. a transmission with an odd number of 1 bits), it knows there is an error. @@ -18,25 +20,28 @@ A parity bit must then be inserted after every seven bits of data: ↑ ↑ ↑ ↑ (7th bits) ``` -So transmission sequence for this message looks like this: +The transmission sequence for this message looks like this: ```text -1100000_ β”‚ 0000000_ β”‚ 0111000_ β”‚ 0001101_ β”‚ 1110 - ↑ ↑ ↑ ↑ (parity bit locations) + 1st β”‚ 2nd β”‚ 3rd β”‚ 4th β”‚ 5th + transmission β”‚ transmission β”‚ transmission β”‚ transmission β”‚ transmission + β”‚ β”‚ β”‚ β”‚ + 1100000_ β”‚ 0000000_ β”‚ 0111000_ β”‚ 0001101_ β”‚ 1110 + ↑ ↑ ↑ ↑ (parity bit locations) ``` The data in the first transmission in the sequence (`1100000`) has two 1 bits (an even number), so the parity bit is 0. The first transmission becomes `11000000` (or `C0` in hex). -The data in the next transmission (`0000000`) has none (an even number again), so the parity bit is 0 again. -The second transmission becomes `00000000` (or `00` in hex). +The data in the next transmission (`0000000`) has zero 1 bits (an even number again), so the parity bit is 0 again. +The second transmission thus becomes `00000000` (or `00` in hex). The data for the next two transmissions (`0111000` and `0001101`) have three 1 bits. Their parity bits are set to 1 so that they have an even number of 1 bits in the transmission. They are transmitted as `01110001` and `00011011` (or `71` and `1B` in hex). The last transmission (`1110`) has only four bits of data. -Since exactly eight bits are transmitted at a time and the parity bit is the right most bit, three 0 bits and then the parity bit is added to make up eight bits. +Since exactly eight bits are transmitted at a time and the parity bit is the right most bit, three 0 bits and then the parity bit are added to make up eight bits. It now looks like this (where `_` is the parity bit): ```text @@ -44,9 +49,7 @@ It now looks like this (where `_` is the parity bit): ↑↑↑ (added 0 bits) ``` -There is an odd number of 1 bits again, so the parity bit is to 1. +There is an odd number of 1 bits again, so the parity bit is 1. The last transmission in the sequence becomes `11100001` (or `E1` in hex). -The entire transmission sequence for this message then `11000000 00000000 01110001 00011011 11100001` (or `C0 00 71 1B E1` in hex). - -Your job is to help implement the message sequencer to calculate the transmission sequence and the decoder for receiving messages. +The entire transmission sequence for this message is `11000000 00000000 01110001 00011011 11100001` (or `C0 00 71 1B E1` in hex). diff --git a/exercises/intergalactic-transmission/introduction.md b/exercises/intergalactic-transmission/introduction.md index d8067a00d1..32a44494c1 100644 --- a/exercises/intergalactic-transmission/introduction.md +++ b/exercises/intergalactic-transmission/introduction.md @@ -10,8 +10,8 @@ Now imagine the consequences: - Losing contact with the Kepler Whirl system when "save new worm hole" becomes "cave new worm hole". - Or plunging the universe into existential horror by replacing a cowboy emoji 🀠 with a clown emoji 🀑. -Detecting corrupted messages isn’t just important β€” it’s critical. -The receiver must know when something has gone wrong before disaster strikes. +Detecting corrupted messages isn’t just important β€” it's critical. +The receiver _must_ know when something has gone wrong before disaster strikes. But how? Scientists and engineers from across the universe have been battling this problem for eons. From eb8ef7696498709799f1ff6830189ab23c471d17 Mon Sep 17 00:00:00 2001 From: Kah Goh Date: Wed, 9 Apr 2025 07:48:20 +0800 Subject: [PATCH 07/12] Fix canonical data & minor corrections in Markdown files --- exercises/intergalactic-transmission/canonical-data.json | 4 ++-- exercises/intergalactic-transmission/instructions.md | 7 +++---- exercises/intergalactic-transmission/introduction.md | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/exercises/intergalactic-transmission/canonical-data.json b/exercises/intergalactic-transmission/canonical-data.json index 2a5457dd1a..e473384f20 100644 --- a/exercises/intergalactic-transmission/canonical-data.json +++ b/exercises/intergalactic-transmission/canonical-data.json @@ -25,12 +25,12 @@ }, { "uuid": "97f27f98-8020-402d-be85-f21ba54a6df0", - "description": "0x02 is transmitted as 0x0100", + "description": "0x02 is transmitted as 0x0300", "property": "transmitSequence", "input": { "message": ["0x02"] }, - "expected": ["0x01", "0x00"] + "expected": ["0x03", "0x00"] }, { "uuid": "24712fb9-0336-4e2f-835e-d2350f29c420", diff --git a/exercises/intergalactic-transmission/instructions.md b/exercises/intergalactic-transmission/instructions.md index 3d33287a3e..a8f5bd551a 100644 --- a/exercises/intergalactic-transmission/instructions.md +++ b/exercises/intergalactic-transmission/instructions.md @@ -1,16 +1,15 @@ # Instructions -Your job is to help implement the message sequencer to calculate the transmission sequence and the decoder for receiving messages. +Your job is to help implement the message sequencer, which calculates the transmission sequence, and the decoder for receiving messages. A parity bit is simple way of detecting transmission errors. The transmitters and receivers can only transmit and receive _exactly_ eight bits at a time (including the parity bit). The parity bit is set so that there is an _even_ number 1s in each transmission and is always the first bit from the right. So if the receiver receives `11000001`, `01110101` or `01000000` (i.e. a transmission with an odd number of 1 bits), it knows there is an error. -However, messages are rarely this short. -The message needs to be transmitted in a sequence when they are longer. +However, messages are rarely this short, and need to be transmitted in a sequence when they are longer. -For example, consider the message `11000000 00000001 11000000 11011110` (or in `C0 01 C0 DE` hex). +For example, consider the message `11000000 00000001 11000000 11011110` (or `C0 01 C0 DE` in hex). Since each transmission contains exactly eight bits, it can only contain seven bits of data and the parity bit. A parity bit must then be inserted after every seven bits of data: diff --git a/exercises/intergalactic-transmission/introduction.md b/exercises/intergalactic-transmission/introduction.md index 32a44494c1..217c088018 100644 --- a/exercises/intergalactic-transmission/introduction.md +++ b/exercises/intergalactic-transmission/introduction.md @@ -10,7 +10,7 @@ Now imagine the consequences: - Losing contact with the Kepler Whirl system when "save new worm hole" becomes "cave new worm hole". - Or plunging the universe into existential horror by replacing a cowboy emoji 🀠 with a clown emoji 🀑. -Detecting corrupted messages isn’t just important β€” it's critical. +Detecting corrupted messages isn't just important β€” it's critical. The receiver _must_ know when something has gone wrong before disaster strikes. But how? From f3b75b4fdb4188a7d876b6974085272c1b8c7c93 Mon Sep 17 00:00:00 2001 From: Kah Goh Date: Wed, 9 Apr 2025 17:37:05 +0800 Subject: [PATCH 08/12] Use bullet list for task list --- exercises/intergalactic-transmission/instructions.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/exercises/intergalactic-transmission/instructions.md b/exercises/intergalactic-transmission/instructions.md index a8f5bd551a..a2acfdfff5 100644 --- a/exercises/intergalactic-transmission/instructions.md +++ b/exercises/intergalactic-transmission/instructions.md @@ -1,6 +1,9 @@ # Instructions -Your job is to help implement the message sequencer, which calculates the transmission sequence, and the decoder for receiving messages. +Your job is to help implement the following: + +- the message sequencer, which calculates the transmission sequence +- the decoder, which decodes the messages A parity bit is simple way of detecting transmission errors. The transmitters and receivers can only transmit and receive _exactly_ eight bits at a time (including the parity bit). From 1defb901b7ef5c83c6e71789ef05e08f8c65dbb9 Mon Sep 17 00:00:00 2001 From: Kah Goh Date: Wed, 9 Apr 2025 22:14:51 +0800 Subject: [PATCH 09/12] Apply suggestions from review Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> --- exercises/intergalactic-transmission/instructions.md | 7 ++----- exercises/intergalactic-transmission/introduction.md | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/exercises/intergalactic-transmission/instructions.md b/exercises/intergalactic-transmission/instructions.md index a2acfdfff5..665093deef 100644 --- a/exercises/intergalactic-transmission/instructions.md +++ b/exercises/intergalactic-transmission/instructions.md @@ -25,11 +25,8 @@ A parity bit must then be inserted after every seven bits of data: The transmission sequence for this message looks like this: ```text - 1st β”‚ 2nd β”‚ 3rd β”‚ 4th β”‚ 5th - transmission β”‚ transmission β”‚ transmission β”‚ transmission β”‚ transmission - β”‚ β”‚ β”‚ β”‚ - 1100000_ β”‚ 0000000_ β”‚ 0111000_ β”‚ 0001101_ β”‚ 1110 - ↑ ↑ ↑ ↑ (parity bit locations) +1100000_ 0000000_ 0111000_ 0001101_ 1110 + ↑ ↑ ↑ ↑ (parity bits) ``` The data in the first transmission in the sequence (`1100000`) has two 1 bits (an even number), so the parity bit is 0. diff --git a/exercises/intergalactic-transmission/introduction.md b/exercises/intergalactic-transmission/introduction.md index 217c088018..f19dffbead 100644 --- a/exercises/intergalactic-transmission/introduction.md +++ b/exercises/intergalactic-transmission/introduction.md @@ -16,7 +16,7 @@ The receiver _must_ know when something has gone wrong before disaster strikes. But how? Scientists and engineers from across the universe have been battling this problem for eons. Entire cosmic AI superclusters churn through the data. -And then, one day, a legend resurfaces - an ancient, powerful method, whispered in debugging forums, muttered by engineers who've seen too much... +And then, one day, a legend resurfaces β€” an ancient, powerful method, whispered in debugging forums, muttered by engineers who've seen too much... The Parity Bit! From 750625d8c0eaca25b8068d86453e6d6d36ff2a05 Mon Sep 17 00:00:00 2001 From: Kah Goh Date: Wed, 9 Apr 2025 22:15:46 +0800 Subject: [PATCH 10/12] Fix alignment Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> --- exercises/intergalactic-transmission/instructions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/intergalactic-transmission/instructions.md b/exercises/intergalactic-transmission/instructions.md index 665093deef..55a78269f5 100644 --- a/exercises/intergalactic-transmission/instructions.md +++ b/exercises/intergalactic-transmission/instructions.md @@ -19,7 +19,7 @@ A parity bit must then be inserted after every seven bits of data: ```text 11000000 00000001 11000000 11011110 - ↑ ↑ ↑ ↑ (7th bits) + ↑ ↑ ↑ ↑ (7th bits) ``` The transmission sequence for this message looks like this: From 7228710611823bd1bc32e6c583ade22d41faaddb Mon Sep 17 00:00:00 2001 From: Kah Goh Date: Thu, 10 Apr 2025 20:44:07 +0800 Subject: [PATCH 11/12] Apply suggestions from review --- exercises/intergalactic-transmission/canonical-data.json | 2 +- exercises/intergalactic-transmission/instructions.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/exercises/intergalactic-transmission/canonical-data.json b/exercises/intergalactic-transmission/canonical-data.json index e473384f20..f14035cade 100644 --- a/exercises/intergalactic-transmission/canonical-data.json +++ b/exercises/intergalactic-transmission/canonical-data.json @@ -298,7 +298,7 @@ }, { "uuid": "6065b8b3-9dcd-45c9-918c-b427cfdb28c1", - "description": "last byte in seven byte message has wrong parity", + "description": "last byte has wrong parity", "property": "decodeMessage", "input": { "message": [ diff --git a/exercises/intergalactic-transmission/instructions.md b/exercises/intergalactic-transmission/instructions.md index 55a78269f5..b356e625f5 100644 --- a/exercises/intergalactic-transmission/instructions.md +++ b/exercises/intergalactic-transmission/instructions.md @@ -1,9 +1,9 @@ # Instructions -Your job is to help implement the following: +Your job is to help implement -- the message sequencer, which calculates the transmission sequence -- the decoder, which decodes the messages +- the message sequencer, which calculates the transmission sequence, and +- the decoder, which decodes it. A parity bit is simple way of detecting transmission errors. The transmitters and receivers can only transmit and receive _exactly_ eight bits at a time (including the parity bit). From 0e5de596582bd5be83b62147bc5e301090de5973 Mon Sep 17 00:00:00 2001 From: Kah Goh Date: Fri, 11 Apr 2025 06:47:24 +0800 Subject: [PATCH 12/12] Apply missed suggestion --- exercises/intergalactic-transmission/instructions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/intergalactic-transmission/instructions.md b/exercises/intergalactic-transmission/instructions.md index b356e625f5..63fe661e02 100644 --- a/exercises/intergalactic-transmission/instructions.md +++ b/exercises/intergalactic-transmission/instructions.md @@ -2,8 +2,8 @@ Your job is to help implement -- the message sequencer, which calculates the transmission sequence, and -- the decoder, which decodes it. +- the transmitter, which calculates the transmission sequence, and +- the receiver, which decodes it. A parity bit is simple way of detecting transmission errors. The transmitters and receivers can only transmit and receive _exactly_ eight bits at a time (including the parity bit).