I've actually already implemented Alex's solution, and it worked; I'll leave it at that for the moment, since this assignment is currently live in the hands of students, so I don't want to mess with it too much (in particular, I don't want to risk re-randomizing the numbers out from under the students)!
Once the semester is over and I have time to tidy up my code, I'll come back to this.
Thanks so much for the additional info and suggestions!
(I still have so much to learn...)
- Alice (no programming background, just muddling along here!)