On Productivity

We run a driving theory course as part of our outreach and Christian love for the young people we work with. The logic goes; our young people are dropping out of education with no qualifications, they want money, realise that getting a job isn’t that easy and then realise that they need qualifications for a good job. Also, they want to learn to drive. But for the above reasons they can’t afford to learn to drive. Also, it turns out that having a driving license is a pretty good qualification. So we teach young people the highway code in small numbers every few months so they can pass the driving theory test. Hopefully one day we’ll be able to teach them all of the driving test, but the theory gets them farther along that way. We do all this because it is a a loving act. You should try them some day, they’re pretty neat.

Anyway, today saw me making a introduction quiz with some of the questions that you might be tested on during the driving theory test. Pick a random question from the driving theory test bumper question book, type it up, then repeat. Except it’s hard to pick a random question from a book, after all, a book pretty much always falls open near the middle (Section 9: Motorway Rules). So I wrote some 3 lines of php code to pick a random section (out of the 14 sections) and then a random number out of the maximum number of questions in a section (155).

echo rand(0,14);
echo '<br />';
echo rand(0,155);

So I started using that. And then I realised that it had a bug in that 0-14 is inclusive of 0, and there is no section 0 (unless you count ‘a message from the Chief Driving Examiner’, but that has no questions so I don’t). So I rewrote the code.

echo rand(1,14);
echo '<br />';
echo rand(1,155);

But lo, it wasn’t very long before I realised that if it selected a question in any of the smaller sections (eg Section 14: Vehicle Loading or Section 12: Documents) then the number for the question would far too often be far too high. I mean, Section 2: Attitude only has 49 questions in it, what do I do if the number generator pulls out a 127?. So I decided to rewrite it to make it useful every time.

$sectionlist = array(0,39,49,114,56,98,86,63,66,76,155,41,79,15);
$section = rand(1,14);
echo $section;
echo '<br />';
echo rand(1,$sectionlist[$section]);

And then on the way to lunch I realised that it was still going to be biased to the shorter sections and so actually I needed to work out how to weight answers to certain sections. And then I realised OH DEAR ME WHAT ON EARTH WAS I DOING.

And so that, in short, is how we’ll all live happier and more productive lives because of the ever growing abundance of technology in the world.