Code Room
Vibe codingHardvc-g263
Subject Ai code reviewLevel Senior–Staff~18 minCommon in Algorithms & data structures interviewsIndustries Technology

Question

An AI wrote this LR-warmup training loop. It trains, but the learning rate never reaches its peak and the final step is skipped. Find the off-by-one(s).

python
warmup_steps = 1000for step in range(1, total_steps):           # start at 1    lr = base_lr * min(step / warmup_steps, 1.0)    set_lr(opt, lr)    batch = data[step * bs : step * bs + bs]    loss = train_step(model, batch)    if step % eval_every == 0:        evaluate(model)save_checkpoint(model)
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.

Describe your solution

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.