#C# Hyper-optimized Telementary idk what to do anymore

3 messages · Page 1 of 1 (latest)

dense ermine
#

I expected this to be a pretty easy exercise cause it only is supposed to explain the concept, but it's the first Exercise I can't finish somehow.

Console.WriteLine("Long: " + reading.ToString());
byte[] bytes = BitConverter.GetBytes(reading);
Console.WriteLine("Bytes:");
Console.WriteLine(BitConverter.ToString(bytes));
return bytes;

I thought just using BitConverter.GetBytes would be enough to do this. But the arrays will not be what the test results wanna see.
After trying to check the values with WriteLine and asking ChatGPT I still can't understand what I'm supposed to do so I hope someone here can help me with this exercise.

Thanks in advance.

Second function where we use ToInt also doesn't work how I expected this to be...

#

Long value: 9223372036854775807
Byte array value:
FF-FF-FF-FF-FF-FF-FF-7F

This is the Output of the WriteLines for the first Test btw

and this is the first tests result
Expected: [248, 255, 255, 255, 255, ...]
Actual: [255, 255, 255, 255, 255, ...]

oblique wadi
#

I haven't done any C# exercise yet, but I found this exercise's instructions here: https://github.com/exercism/csharp/blob/main/exercises/concept/hyper-optimized-telemetry/.docs/instructions.md

From what I read in the instructions, calling BitConverter.GetBytes will not be enough. The exercise asks you to implement a protocol to compress the passed-in data to the smallest possible size. You are expected to return a 9-bytes buffer (as a byte[]). The first byte in the buffer is supposed to contain the size of extra bytes used, followed by the bytes containing the data. So you do need to use BitConverter.GetBytes, but not directly.

Read the instructions again, especially the part about the types to use to encode data. Can you think of a way to check what size you need to use depending on the input value?

(As a side note, if you are solving the exercise locally, you could request mentoring - it might be quicker than this forum.)

GitHub

Exercism exercises in C#. Contribute to exercism/csharp development by creating an account on GitHub.