5 points
The challenge is to receive bytes and extract some numbers from those bytes.
Connect to the problem endpoint, grab a base64
-encoded pack of bytes, unpack the required values from it and send them back.
The pack contains, always in the following order:
int
(signed), to start offunsigned int
short
(signed) to make things interestingfloat
because floating point is importantdouble
as welldouble
but this time in big endian (network byte order)In case you're wondering, we're using 4 byte ints
, so everything is in the context of a 32-bit platform.
Extract those numbers from the byte string and send them back to the solution endpoint for your reward. See the solution section for a description of the expected JSON format.
GET /challenges/help_me_unpack/problem?access_token=...
Problem JSON format will be in the following format:
bytes
: base64 encoded bytes that you have to unpack
POST /challenges/help_me_unpack/solve?access_token=...
Solution JSON structure:
int
: the signed integer valueuint
: the unsigned integer valueshort
: the decoded short
valuefloat
: surprisingly, the float valuedouble
: the double value - shockinglybig_endian_double
: you get the idea by now!To make things easier, the response will usually include info about which value you got wrong and what was the expected value.
This challenge is actually inspired in part by the Redis one challenge, where reading things from raw bytes is sort of necessary. I also figured h^
really needed a simple, first-timer friendly challenge with a simple premise, and here it is!
By the way, I was always slightly fascinated by how floating point things are stored. The IEEE754 format is actually really, really neat - it's just that people in general suck at explaning it (jumping straight to math, which is lazy). If you want to read more into it, I can wholeheartedly recommend floating point visually explained. It's a great piece.
h^
by buying me a coffee. Cheers!h^
profile is here.