The ‘random’ problem

Update: I will be doing another run back through these problems and for now will be including the need for the random.seed to be set to 1 for testing. If your students are trying to tackle these problems, they can obviously set the seed to the default while creating their code but the tests will expect the seed to be 1 in order to pass. I think this should make a good discussion around what random actually is and why setting it to a standard value is important when testing. Most of these style projects now have tests linked to them which should work but I will have another pass at some point later. Thanks for your patience!


Thought I would drop by before I finish for the evening. I am currently working my way through the T2C projects, and unit 4 should be available in the next day or two.

However, adding unit 4 has slowed me down a little…I’ve hit a small issue that will ultimately need resolving, and its because of random numbers. How do you test the inputs and outputs of a problem, when the outputs are ‘random’ and the potential inputs are based on a random value.

For example, in the guessing game problem, the value to guess is random so there is no way of knowing which combination of numbers entered will lead to the correct answer, or indeed what the correct answer will be for the output.

Now in my initial GoCodeIt problems I anticipated this and there is functionality to deal with random values (and several other problems). I won’t go into the detail here but it involves ensuring the code will allow the user to enter a value rather than a random value for testing. After all, if we know the number to be guessed, using the above example, then we know what outputs will be produced for a given set of inputs.

Now onto T2C. The problems do not work the same way as the GoCodeIt problems. The method used to currently inject additional code into the problem for testing does not work. So I’ve had to have a ‘good think’, like we all have to do from time to time.

Sometimes, going away and having a good think about the problem you are trying to solve can have unexpected benefits, as it has in this case. There has been something bothering me about my existing method that I didn’t like…and this could potentially lead to an improvement in my current testing methods.

So while there have been a couple of hurdles to incorporating T2C into GoCodeIt, and these have, for a short time, slowed the process down, hopefully the outcome will not only be a wider selection of excellent problems to choose from but also a more flexible testing system allowing for some unique problems to be automarked.

It’s all in my head at the moment…and I’m not in a place to move to code yet, but I have confidence the issue can be resolved…

What does this mean?

Well, sadly, at the moment it means that any of the T2C problems that include a random element will not be able to be automarked for a short time. I hope that is something you can live with temporarily – there are only a handful (2 so far!) of the well over 200 projects that will eventually be available that this will affect, and it will be resolved one way another when I move back to tool development and site improvement…and there is quite a list improvements to get through.

In the meantime, now I have resolved how I will approach the T2C problems I can start to build these out a little more rapidly, and I am looking forward to getting these all in your hands as soon as possible.

Thanks for all your support now and in the future!

Categories:

2 responses to “The ‘random’ problem”

  1. Ian Chesworth Avatar

    Hi,

    First of all a big thanks for developing this site: we are a school in Malaysia teaching the International GCSE and A Level (Cambridge) and am finding it really useful for tracking student progress through their Python journey.

    One of our students noticed that for his Time2Code, Dungeon Master from Level 4 it is always failing Test 2. I’ve tried myself and can’t get it to pass too so maybe a problem with the testing setup.

    Another problem I’ve noticed is that quite a lot of our students here in Malaysia (mix of nationalities) tend to have THREE names which causes a problem when I register them. I’ve got around this by them either choosing just one or by them concatenating them e.g. JoeFred Bloggs. Just thought I’d mention it for when you roll out the full course.

    Once again, thanks!

    1. hudspeter Avatar

      Hi, thanks for the feedback. Amazing to hear it being used in Malaysia BTW!. I will look at the names at some point but if you have a workaround for now that will be the best approach. As for the Dungeon Master problem – yes the tests were not right. Think I’ve fixed those now.

Leave a Reply

Your email address will not be published. Required fields are marked *