Skip to content

Add intergalactic-transmission #1062

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 2 commits into from
Jun 14, 2025
Merged

Conversation

ahans
Copy link
Contributor

@ahans ahans commented Jun 14, 2025

Reviewed this over at arm64-assembly and think it's a nice exercise, so I figured I'd add it here!

The test file is taken from the arm64 track with minor modifications. Over there we have generators for all test files. What would other reviewers maintainers think of introducing something like that here as well?


#define WRONG_PARITY -1

int transmit_sequence(uint8_t *buffer, const uint8_t *message,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The focus of this exercise is on the encoding/decoding logic and not so much on figuring out function signatures. As a student I always find it annoying having to figure those out myself when i actually want to focus on the problem at hand, so I kept them here. Let me know if you think they should be removed.

@ahans ahans added x:module/practice-exercise Work on Practice Exercises x:type/content Work on content (e.g. exercises, concepts) x:rep/large Large amount of reputation labels Jun 14, 2025
@ryanplusplus
Copy link
Member

Over there we have generators for all test files. What would other reviewers think of introducing something like that here as well?

As long as we can keep complexity in check, I'm in favor.


#define BUFFER_SIZE 100
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define WRONG_PARITY -1
Copy link
Member

Choose a reason for hiding this comment

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

I think this already comes from intergalactic_transmission.h

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Removed.

uint8_t const payload = message[i] >> 1;
uint8_t const parity = message[i] & 1;
// check parity bit and return early if mismatch found
if ((__builtin_popcount(payload) & 1) != parity)
Copy link
Member

Choose a reason for hiding this comment

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

👍

@ahans
Copy link
Contributor Author

ahans commented Jun 14, 2025

Over there we have generators for all test files. What would other reviewers think of introducing something like that here as well?

As long as we can keep complexity in check, I'm in favor.

Alright, I will experiment a bit and create an issue so we can discuss (or maybe it'll be a PR already).

@ryanplusplus ryanplusplus merged commit 361be80 into main Jun 14, 2025
4 checks passed
@ryanplusplus ryanplusplus deleted the ahans/intergalactic-transmission branch June 14, 2025 21:37
@ryanplusplus
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x:module/practice-exercise Work on Practice Exercises x:rep/large Large amount of reputation x:type/content Work on content (e.g. exercises, concepts)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants