Parse and build binary data in Python | OpenAI Interview Question