exercism / csharp

Exercism exercises in C#.
https://exercism.org/tracks/csharp
MIT License
344 stars 346 forks source link

C# track, Hyper-optimized Telemetry exercise - unclear instructions #2160

Closed vlabensky-sana closed 8 months ago

vlabensky-sana commented 1 year ago

Hello,

In the Hyper-optimized Telemetry exercise of the C# track the last paragraph seems to give vague sentence which contradicts the task.

Here's the exercise

The last paragraph goes like this:

  1. Decode a received buffer

Please implement the static method TelemetryBuffer.FromBuffer() to decode the buffer received and return the value in the form of a long.

TelemetryBuffer.FromBuffer(new byte[] {0xfc, 0xff, 0xff, 0xff, 0x7f, 0x0, 0x0, 0x0, 0x0 })
// => 2147483647

If the prefix byte is not one of -8, -4, -2, 2 or 4 then 0 should be returned.

In the last sentence it says that if the prefix byte is not one of -8, -4, -2, 2 or 4 then 0 should be returned. But at the same time in the example above it has the prefix byte 0xFC, which is 252, which is none of the numbers listed in the last sentence, and the returned type is expected to be 2147483647 which contradicts the 0 from the last sentence.

So this last sentence - what is it supposed to mean? Perhaps it needs to re-phrased to make it more clear for the reader.

Thanks!

github-actions[bot] commented 1 year ago

Hello. Thanks for opening an issue on Exercism. We are currently in a phase of our journey where we have paused community contributions to allow us to take a breather and redesign our community model. You can learn more in this blog post. As such, all issues and PRs in this repository are being automatically closed.

That doesn't mean we're not interested in your ideas, or that if you're stuck on something we don't want to help. The best place to discuss things is with our community on the Exercism Community Forum. You can use [this link](https://forum.exercism.org/new-topic?title=C#%20track,%20Hyper-optimized%20Telemetry%20exercise%20-%20unclear%20instructions&body=Hello,%0D%0A%0D%0AIn%20the%20Hyper-optimized%20Telemetry%20exercise%20of%20the%20C#%20track%20the%20last%20paragraph%20seems%20to%20give%20vague%20sentence%20which%20contradicts%20the%20task.%0D%0A%0D%0A%5BHere's%20the%20exercise%5D(https://exercism.org/tracks/csharp/exercises/hyper-optimized-telemetry)%0D%0A%0D%0AThe%20last%20paragraph%20goes%20like%20this:%0D%0A%0D%0A%3E%202.%20Decode%20a%20received%20buffer%0D%0A%3E%20%0D%0A%3E%20Please%20implement%20the%20static%20method%20TelemetryBuffer.FromBuffer()%20to%20decode%20the%20buffer%20received%20and%20return%20the%20value%20in%20the%20form%20of%20a%20long.%0D%0A%3E%20%0D%0A%3E%20%60%60%60%0D%0A%3E%20TelemetryBuffer.FromBuffer(new%20byte%5B%5D%20%7B0xfc,%200xff,%200xff,%200xff,%200x7f,%200x0,%200x0,%200x0,%200x0%20%7D)%0D%0A%3E%20//%20=%3E%202147483647%0D%0A%3E%20%60%60%60%0D%0A%3E%0D%0A%3E%20If%20the%20prefix%20byte%20is%20not%20one%20of%20-8,%20-4,%20-2,%202%20or%204%20then%200%20should%20be%20returned.%0D%0A%0D%0AIn%20the%20last%20sentence%20it%20says%20that%20if%20the%20prefix%20byte%20is%20not%20one%20of%20-8,%20-4,%20-2,%202%20or%204%20then%200%20should%20be%20returned.%20But%20at%20the%20same%20time%20in%20the%20example%20above%20it%20has%20the%20prefix%20byte%200xFC,%20which%20is%20252,%20which%20is%20none%20of%20the%20numbers%20listed%20in%20the%20last%20sentence,%20and%20the%20returned%20type%20is%20expected%20to%20be%202147483647%20which%20contradicts%20the%200%20from%20the%20last%20sentence.%0D%0A%0D%0ASo%20this%20last%20sentence%20-%20what%20is%20it%20supposed%20to%20mean?%20Perhaps%20it%20needs%20to%20re-phrased%20to%20make%20it%20more%20clear%20for%20the%20reader.%0D%0A%0D%0AThanks!&category=csharp) to copy this into a new topic there.


Note: If this issue has been pre-approved, please link back to this issue on the forum thread and a maintainer or staff member will reopen it.

ErikSchierboom commented 1 year ago

So this last sentence - what is it supposed to mean? Perhaps it needs to re-phrased to make it more clear for the reader.

Do you perhaps have a better suggestion for how to handle this?

vlabensky-sana commented 1 year ago

As I understood the task, the only valid values of the prefix byte are these:

If that's correct it means that if any of 2, 4, 8, 248, 252 or 254 is passed as a prefix byte to TelemetryBuffer.FromBuffer method then the method will return correct numeric value. If the prefix byte is none of these six values, then the method will return 0. If what I just said is correct then shouldn't the last sentence say this:

If the prefix byte is not one of 2, 4, 8, 248, 252 or 254 then 0 should be returned.

instead of this If the prefix byte is not one of -8, -4, -2, 2 or 4 then 0 should be returned.?

Or perhaps it can be removed completely. Or it may be less specific, like If the prefix byte is of unexpected value then 0 should be returned.

ErikSchierboom commented 1 year ago

If the prefix byte is of unexpected value then 0 should be returned.

I like that! Would you be willing to submit a PR?

vlabensky-sana commented 1 year ago

Took me a while to get back to it, sorry. Here's the PR #2163.

michalporeba commented 8 months ago

@ErikSchierboom The PR has been merged, I think this issue can be closed.