Checkpoint: Safe Accumulator + Honest Probe
Challenge on lesson: Checkpoint: Assume Nothing
CHALLENGE
Difficulty: advanced+25 XP
Implement three functions:
1. int safe_accum(int init, const int *deltas, size_t n, int *out) โ repeatedly add each delta using your overflow-guard pattern; on any overflow return 0 leaving *out untouched; on success store the total and return 1.
2. unsigned int hash_span(const unsigned char *bytes, size_t n) โ FNV-1a over the bytes (offset basis 2166136261u, prime 16777619u) โ defined wraparound by design.
3. int probe_kept(int (*work)(void), int expected) โ volatile file-scope static int probe = 0; is in your editor; reset it, run work(), return 1 iff probe == expected. work() itself increments probe.
Press Submit to check your solution.
Back to lesson: Checkpoint: Assume Nothing