Random Seeding using Scratchpad & Input

Random Seeding using Scratchpad & Input

by Mike McDowell -
Number of replies: 0

Hey all,

If anyone is searching this I've been using a crude but reasonably effective hack for random seeding for students that use the "Run" button with input in their code.

We're using CR for python and often have intro (high school) students use input in their programs. For one assignment, we ask them to have the "computer" randomly pick a number between 1 and 30. The user needs to guess a number and the program respond higher/lower based on that input. Our issue was, with each input, the entire program would re-run and a new random (number to guess) would be chosen. We could seed tests just fine, but pressing the "Run" button reseeded with each input.

The solution? Seed the subproc_code code with the length (number) of characters of the the student prior to running any student code. This means during the run they will always get the same number. If they make any change to their code, they get a new random number. If they notice and mention it, tell them to put a space in their code or scratchpad and it will pick a new one.

Not ideal, but works for high school tests for us. 


Take care all and keep on keepin' on! THANK YOU for giving us CodeRunner!!!