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

Add intergalactic-transmission exercise #2543

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kahgoh
Copy link
Member

@kahgoh kahgoh commented Mar 7, 2025

This is a proposal for a parity bit exercise.

I've created a proof of concept: exercism/csharp#2398

Note, I wasn't quite sure how best to represent byte data in the JSON. I've used an array of strings with the hex values as Visual Code was telling me "expected comma" if I didn't use the string.

@kahgoh kahgoh requested a review from a team as a code owner March 7, 2025 23:27

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The entire message, itself, is sequence of a number of bytes.
The message is a sequence of bytes.

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 transmitters and receivers can only transmit and receive one byte at a time, so a parity bit needs to be added every eighth bit.

Also as a layperson, I’m already a bit confused by bit vs byte so we may want to simplify.

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. If the last group has less than 7 bits, append some 0s to pad the group to 7 bits.
2. If the last group has less than 7 bits, append 0s until that group has 7 bits.

What are the 0s signifying?

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
4. If the group has an even number of 1s or none at all, append a 0 to the group. Otherwise, append 1 if there is an odd number of 1s.


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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The rest have three, so they append 1.
The rest have three each, so they append 1.


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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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, even the flap of a space butterfly's wing can cause a random bit to change during transmission.

We haven’t introduced what flipping signifies.

@@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The double "to" in this sentence might be worth changing.


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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop the "they". There is no "them" in the other steps.

| C 0 | 0 0 | 7 1 | 1 B | E 1 | (in hex)
```

Thus, the transmission sequence is 0xC0_00_71_1B_E1.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Thus, the transmission sequence is 0xC0_00_71_1B_E1.
The resulting transmission sequence is `0xC0_00_71_1B_E1`.


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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 flip in transmission.

- 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Thus, detecting corrupted messages isn’t just important — it’s critical.
Detecting corrupted messages isn’t just important — it’s critical.

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 ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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...

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The Parity Bit.
The Parity Bit!

title = "Intergalactic Transmission"
blurb = "Add parity bits to a message for transmission"
source = "Kah Goh"
source_url = ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe link to this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants