Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Trending in AI
Hot
Agentic AI EngineerForward-Deployed EngineerGenAI EngineerAI Architect
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Start free
Debugging Telemetry Frame Decoding Bugs
00:00
5 left

Debugging Telemetry Frame Decoding Bugs

HardPython

Problem

You're a software engineer at RTX working on ground-side telemetry decoding for a sensor payload. Frames arrive over a serial link as raw bytes; a small C module validates each frame, decodes a big-endian sensor reading, accumulates a checksum recursively, and tracks the largest reading seen so far. In bench testing the decoder either hangs, crashes, or reports readings that don't match what the test rig actually sent.

#include <stdint.h>

#define FRAME_SIZE 8
#define IS_VALID_FRAME(f) f[0] == 0xAA && f[1] == 0x55

int32_t bytes_to_int32_be(uint8_t *bytes) {
    return (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3];
}

int checksum_recursive(uint8_t *frame, int index) {
    if (index == FRAME_SIZE) {
        return 0;
    }
    return frame[index] + checksum_recursive(frame, index);
}

int32_t find_max_reading(int32_t *readings, int count) {
    int32_t max = 0;
    for (int i = 0; i < count; i++) {
        if (readings[i] > max) {
            max = readings[i];
        }
    }
    return max;
}

void process_telemetry_frame(uint8_t *frame, int32_t *readings_out, int *count_out) {
    if (IS_VALID_FRAME(frame) == 0) {
        return;
    }

    int32_t reading = bytes_to_int32_be(&frame[2]);
    readings_out[*count_out] = reading;
    *count_out = *count_out + 1;
}

Find every bug in this program: there's a macro-expansion bug, a recursion bug, an endianness/casting bug, and a couple of logic bugs around the max-value and buffer tracking. Walk through each one, exactly how it manifests, and how you'd fix it.

Use audit_decoder(source_code) and return the findings in source order as a list of objects containing bug, manifestation, and fix. The supplied source text is the decoder shown above.

Constraints

  • source_code is a string identifying the supplied decoder source
  • Return exactly five findings
  • Findings must be ordered by the first appearance of each defect
  • Each finding must contain bug, manifestation, and fix

Function Signature

def audit_decoder(source_code):
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements are in the Question tab.

Sign up free to run or submit. Log in
Code
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 2
Run your code to see test output here.