Code Room
Vibe codingHard
Question
An AI assistant produced this C++ to find the index of a target in a sorted vector, returning a default when absent, for a hot lookup path:
int find_index(const std::vector<int>& v, int target) { int lo = 0, hi = v.size(); while (lo < hi) { int mid = (lo + hi) / 2; if (v[mid] == target) return mid; if (v[mid] < target) lo = mid + 1; else hi = mid; } return -1;}It returns correct indices in unit tests on a 10-element vector. What latent bugs would a staff engineer flag?
What a strong answer looks like
Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.