Skip to content

Commit cbfcebd

Browse files
committed
Revise instructions & introduction
1 parent 28ea0f0 commit cbfcebd

File tree

3 files changed

+42
-26
lines changed

3 files changed

+42
-26
lines changed
Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,52 @@
11
# Instructions
22

3-
Your job is to help implement the message sequencer to add the parity bit to the messages and the decoder to receive messages.
3+
A parity bit is simple way of detecting transmission errors.
4+
The transmitters and receives can only transmit and receive *exactly* eight bits at a time (including the parity bit).
5+
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.
6+
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.
47

5-
The entire message, itself, is sequence of a number of bytes.
6-
The transmitters and receivers can only transmit and receive one byte at a time, so parity bit needs to be added every eighth bit.
7-
The algorithm for adding the bits is as follows:
8-
1. Divide the message bits into groups of 7, starting from the left (the message is transmitted from left to right).
9-
2. If the last group has less than 7 bits, append some 0s to pad the group to 7 bits.
10-
3. For each group, determine if there are an odd or even number of 1s.
11-
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.
8+
However, messages are rarely this short.
9+
The message needs to be transmitted in a sequence when they are longer.
1210

13-
For example, consider the message 0xC0_01_C0_DE.
14-
Writing this out in binary and locating every 7th bit:
11+
For example, consider the message `11000000 00000001 11000000 11011110` (or in `C0 01 C0 DE` hex).
12+
13+
Since each transmission contains exactly eight bits, it can only contain seven bits of data and the parity bit.
14+
A parity bit must then be inserted after every seven bits of data:
1515

1616
```text
17-
C 0 0 1 C 0 D E
18-
1100_0000 0000_0001 1100_0000 1101_1110
19-
↑ ↑ ↑ ↑ (7th bits)
17+
11000000 00000001 11000000 11011110
18+
↑ ↑ ↑ ↑ (7th bits)
2019
```
2120

22-
The last group has only 4 bits (0b1110), so three 0 bits are appended to make it 7 bits:
21+
So transmission sequence for this message looks like this:
2322

2423
```text
25-
| 1100_000 | 0000_000 | 0111_000 | 0001_101 | 1110_000 |
24+
1100000_ │ 0000000_ │ 0111000_ │ 0001101_ │ 1110
25+
↑ ↑ ↑ ↑ (parity bit locations)
2626
```
2727

28-
The first group contains two 1s (an even number of 1s), so 0 is appended to the group.
29-
The second group has none, so append 0.
30-
The rest have three, so they append 1.
28+
The data in the first transmission in the sequence (`1100000`) has two 1 bits (an even number), so the parity bit is 0.
29+
The first transmission becomes `11000000` (or `C0` in hex).
30+
31+
The data in the next transmission (`0000000`) has none (an even number again), so the parity bit is 0 again.
32+
The second transmission becomes `00000000` (or `00` in hex).
33+
34+
The data for the next two transmissions (`0111000` and `0001101`) have three 1 bits.
35+
Their parity bits are set to 1 so that they have an even number of 1 bits in the transmission.
36+
They are transmitted as `01110001` and `00011011` (or `71` and `1B` in hex).
37+
38+
The last transmission (`1110`) has only four bits of data.
39+
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.
40+
It now looks like this (where `_` is the parity bit):
3141

3242
```text
33-
| 1100_0000 | 0000_0000 | 0111_0001 | 0001_1011 | 1110_0001 |
34-
| C 0 | 0 0 | 7 1 | 1 B | E 1 | (in hex)
43+
1110 000_
44+
↑↑↑ (added 0 bits)
3545
```
3646

37-
Thus, the transmission sequence is 0xC0_00_71_1B_E1.
47+
There is an odd number of 1 bits again, so the parity bit is to 1.
48+
The last transmission in the sequence becomes `11100001` (or `E1` in hex).
49+
50+
The entire transmission sequence for this message then `11000000 00000000 01110001 00011011 11100001` (or `C0 00 71 1B E1` in hex).
51+
52+
Your job is to help implement the message sequencer to calculate the transmission sequence and the decoder for receiving messages.

exercises/intergalactic-transmission/introduction.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22

33
Trillions upon trillions of messages zip between Earth and neighboring galaxies every millisecond.
44
But transmitting over such long distances is tricky.
5-
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.
5+
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.
66

77
Now imagine the consequences:
8+
89
- Crashing the Intergalactic Share Market when "buy low" turns to "sell now".
910
- Losing contact with the Kepler Whirl system when "save new worm hole" becomes "cave new worm hole".
1011
- Or plunging the universe into existential horror by replacing a cowboy emoji 🤠 with a clown emoji 🤡.
1112

12-
Thus, detecting corrupted messages isn’t just important — it’s critical.
13+
Detecting corrupted messages isn’t just important — it’s critical.
1314
The receiver must know when something has gone wrong before disaster strikes.
1415

1516
But how?
1617
Scientists and engineers from across the universe have been battling this problem for eons.
1718
Entire cosmic AI superclusters churn through the data.
18-
And then, one day, a legend resurfaces - an ancient, powerful method, whispered in debugging forums, muttered by engineers who've seen too much ...
19+
And then, one day, a legend resurfaces - an ancient, powerful method, whispered in debugging forums, muttered by engineers who've seen too much...
1920

20-
The Parity Bit.
21+
The Parity Bit!
2122

2223
A method so simple, so powerful, that it might just save interstellar communication.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
title = "Intergalactic Transmission"
22
blurb = "Add parity bits to a message for transmission"
33
source = "Kah Goh"
4-
source_url = ""
4+
source_url = "https://github.com/exercism/problem-specifications/pull/2543"

0 commit comments

Comments
 (0)