Add intergalactic-transmission exercise#2543
Conversation
|
|
||
| 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. |
There was a problem hiding this comment.
| 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. |
There was a problem hiding this comment.
| 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. |
There was a problem hiding this comment.
| 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. |
There was a problem hiding this comment.
| 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. |
There was a problem hiding this comment.
| 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. | |||
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
| Thus, the transmission sequence is 0xC0_00_71_1B_E1. | |
| The resulting transmission sequence is `0xC0_00_71_1B_E1`. |
…o exercise/intergalactic-transmission
|
Just pushed updates. Ended up re-writing the |
ErikSchierboom
left a comment
There was a problem hiding this comment.
Just a couple of comments! Really looking forward to implementing this
|
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"] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
You're right, it should be 0x03 0x00! I'll update the data.
There was a problem hiding this comment.
» 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.
|
Solution that uses the The second case seems to have a bug. All the other test cases pass. |
Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com>
Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com>
tasxatzial
left a comment
There was a problem hiding this comment.
Verified tests in Clojure and I wasn't able to spot any issues.
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.