Skip to content

Add intergalactic-transmission exercise #2543

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

Merged
merged 13 commits into from
Apr 16, 2025

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.

Verified

This commit was signed with the committer’s verified signature.
ocelotl Diego Hurtado
@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.

@@ -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`.

kahgoh added 5 commits April 4, 2025 22:16

Verified

This commit was signed with the committer’s verified signature.
ocelotl Diego Hurtado

Verified

This commit was signed with the committer’s verified signature.
ocelotl Diego Hurtado
…o exercise/intergalactic-transmission

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@kahgoh
Copy link
Member Author

kahgoh commented Apr 4, 2025

Just pushed updates. Ended up re-writing the instructions.md while working through the comments though 😅.

@kahgoh kahgoh requested review from BNAndras and IsaacG April 4, 2025 14:36
Copy link
Member

@ErikSchierboom ErikSchierboom left a comment

Choose a reason for hiding this comment

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

Just a couple of comments! Really looking forward to implementing this

@ErikSchierboom
Copy link
Member

Looks good! Does anybody have time to test the canonical data by doing an implementation of this exercise?

@IsaacG
Copy link
Member

IsaacG commented Apr 8, 2025

Looks good! Does anybody have time to test the canonical data by doing an implementation of this exercise?

I could write a solution using the canonical data later today.

"input": {
"message": ["0x02"]
},
"expected": ["0x01", "0x00"]
Copy link
Member

Choose a reason for hiding this comment

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

0x02 is 0000 0010. Pad that to 7-bit chunks and you get 0000 001_ | 0000 000_. Add parity bits for 0000 0011 | 0000 0000. Shouldn't the output be 0x03 0x00?

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, it should be 0x03 0x00! I'll update the data.

Copy link
Member

Choose a reason for hiding this comment

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

» python intergalactic_transmission.py https://raw.githubusercontent.com/exercism/problem-specifications/eb8ef7696498709799f1ff6830189ab23c471d17/exercises/intergalactic-transmission/canonical-data.json
{'pass': 26, 'fail': 0}

My solution says the data is correct :D Or, the data says my solution is correct.

@IsaacG
Copy link
Member

IsaacG commented Apr 8, 2025

Solution that uses the canonical_data.json as input: https://gist.github.com/IsaacG/0e628e51c39e44c4ebbc470b64c61675

The second case seems to have a bug. All the other test cases pass.

Co-authored-by: Anastasios Chatzialexiou <[email protected]>
Co-authored-by: Anastasios Chatzialexiou <[email protected]>
kahgoh added 2 commits April 10, 2025 20:46
Copy link
Member

@tasxatzial tasxatzial left a comment

Choose a reason for hiding this comment

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

Verified tests in Clojure and I wasn't able to spot any issues.

@kahgoh kahgoh merged commit 75e16b1 into exercism:main Apr 16, 2025
7 checks passed
@kahgoh kahgoh deleted the exercise/intergalactic-transmission branch April 18, 2025 08:37
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.

None yet

5 participants