In 9th grade, I wrote programs to solve specific kinds of algebra problems while showing the step-by-step "work" on screen. I remember realizing a critical bug in the code during an exam, which surprised me because it worked perfectly for all the homework and study questions.
I ended up spending more time trying to fix it than working on the test! I now realize that it was my first experience with a P1 production bug. In a way, it was my math teacher's fault for not providing sufficient acceptance criteria. I was supposed to learn about polynomials, but I (also) ended up learning about edge cases.