Guess the Date

This is an activity for the classroom that I think illustrates a brute force attack.




The teacher thinks of a date. The students have to guess the date. The students are allowed to ask questions but the teacher is only allowed to answer yes or now.


Typical example should go something like this.

Teacher: I’m thinking of a date.
Student: Is it after July 1st?
Teacher: Yes.
Student: Is it in July?
Teacher: No.
Student: Is it in August.
Teacher: No.
Student: September?
Teacher: No.
Student: October.
Teacher: Yes.
Student: Is it in the first half of the month?
Teacher: Yes.
Student: Is it the 1st?
Teacher: No.
Student: 2nd?
Teacher: No.
Student: 3rd?
Teacher: No.
Student: 4th?
Teacher: Yes. The date was October 4th.


This is an example of how a brute force attack works. The attacker gets what information they can to narrow the field then starts with rapid fire guessing, is it 1? 2? 3? 4? 5?. This technique is pretty commonly used still but isn’t very efficient, and the less information you have to start with the longer it will take over all.


Make sure you don’t think of a date that the students will guess quickly, like the first of January, or any month for that matter. Also avoid the end of the month, otherwise you’ll be there all day. Sticking in the region of  4th – 10th should usually suffice.

You don’t actually have to think of a date, just answer the questions in a manner that will bring out the pattern to illustrate the point. Once you think the point has been illustrated, just tell them they’re correct.

Coding for Kids

Recently I was invited to my son’s primary school to deliver a lesson on coding. I currently teach this to year 9s and I’m moving toward becoming a computer science teacher full time so I graciously accepted the invitation.

First off, I feel the need to clear something up. Coding, and programming are not the same thing. They are separate skills and even have separate, all be in similar, applications.

Coding is language, computer language more specifically. I try to think of it in the same way as a spoken language. I speak english, I like to think that I speak english well and I’m able to use the english language to express myself coherently to all sorts of different people and scenarios. I’ve attempted to learn other languages, Spanish, Japanese and French and found that I have no skill for foriegn languages. In each case I’ve learned some of the vocabulary and grammar but I’ve never got beyond the point of very basic communication.

Coding is the same. I favour two or three languages and dabble in others. While my coding skill is much better than my skill for foreign languages I suffer in the same way as I do with Spanish when I use computer languages with which I’m less familiar where in I am able to perform the basic ‘generic’ functions but not able to utilise the strengths of the language.

Programming is giving instruction. Giving a computer, or anything else a set of instructions that are to be carried out in a specific order. It sounds simple but and it is until those instruction have to include things like selection, looping processes or exception handling.

In terms of computing, coding and programming do go hand in hand. You use code to write a program that the computer can run. Coding doesn’t really exist without programming, which I think is the main reason for the ambiguity. But programming does exist without coding, television, plays, events all have programs and one must be able to compile and understand those programs.

There’s been a big push for getting computer science into schools and exposing students to computer programming at an early age. While I’m all for the push I get the sense that there is quite a bit of confusion about coding and programming in general.

The reason that I feel I need to clarify the difference is that tools such as Scratch, AppInventor and the like are being pitched as a way to teach young students to code and it’s almost a disservice. These applications have been developed in order to bridge the gap between programming and coding and I think they do that as well as can be done. However the visual nature of these tools mean that they are better suited for teaching programming over coding initially.

The Lesson

First I talked a little about computers, what they are and why they are useful. What a program or app is?

The Counter

I found the fastest counter in the class and had them try to count to ten faster than my iPad could. After they lost I had them try to count faster to ten than the iPad can count to 1000. They stand a reasonable chance of winning this one, but only because it’s an old iPad. I then had them race an optimised version of the counting program and showed them just how quickly the computer can really count to 1000, 1000000 and 1000000000.

We then discussed the reasons that the fastest counter couldn’t keep up.

  • Couldn’t speak quickly enough. – a valid point, computers don’t need to speak each of the numbers, but it does need to draw them. Could they write 1 – 10 faster than a computer?
  • The computer probably skipped some numbers. They dared accuse me of cheating.

Afterwards we talked about coding and how computers can follow instructions super quickly as well. Coding is simply a way that we give the computer instructions that it can understand. It will then follow them super-fast and get them right every single time.

Head Shoulders Knees and Toes

This attempted to demonstrate why speedy and flawless instruction following is useful but more shows that humans are generally terrible at it, which is why we invented computers.

The kids stand up and place their hands on the part of their bodies that you call out. If they get it wrong they have to sit down.

  1. Call out everything in order for a bit, then I threw in a few random calls. This eliminates most the class right away.
  2. Call out everything in order but get gradually faster and faster until everyone is out. Doesn’t usually take very long.
  3. Conclude with the class that they are all lousy computers.

We then discussed some of the problems that they had.

  • Couldn’t hear the instructions. – Computers will always hear whatever instructions you pass it.
  • Expected one instruction but was told another. – Computers don’t try to anticipate what the next instruction will be.
  • “I can’t move that fast” – While it is possible to move two quickly for a computer, they are much much faster than humans.


We then moved on to Scratch. I talked briefly about it and then showed them a quick introduction video from the scratch website,

I then demonstrated two example games that I had created in Scratch (link below) and took them through how to make them.

Things to note:

Running Scripts – Scripts will action if they are clicked even if they are not in the scene, or attached to anything. So if you get a child that has accidentally rotated their sprite upside down, just go into motion and click on one of the Rotate script until the sprite is correctly oriented.

Events – Every new action starts with an event. ‘When Greenflag is Clicked’ is a good on to start off with. Basically any set of scripts will need to have some type of event at the top.

Motion – Many of the motion scripts will automatically update according to where the sprite is in the stage. So for example if you wanted to have the sprite start at one location and then glide to another; Drag the sprite to the position at which you want them to start and then move a Go To script onto that sprite. Then reposition the sprite to where you want it to move and drag in a Glide To script. The X and Y of both those scripts will have automatically worked themselves out so that you don’t have to.

I’ve attached the documents that I used below, feel free to use them.



Having my Pi

I’ve had access to this Raspberry Pi for a few weeks now and I feel compelled to post an update regarding how I’m getting on.

First off. I love this little thing. The last few weeks have been an adventure. It’s like I’m back in 5th grade when I was just getting into computers and really getting a feel for what I could do with them. Or when I was 17 and setting up a LAN complete with a ridiculous number of extrenuous servers types with my room-mates in our apartment. Back in the day when we would set up an intranet web and media server just because we didn’t have one, not because it filled any particular need.

Getting back into Linux has been the most daunting part of using the Pi. As much as I love the OS I never really understood it. I also found that Linux, for me, prompts a compulsion toward endless re-configuration. I’ve never had a Linux installation that lasted more than a few days. I just can’t help myself. I fiddle, update and configure until nothing works anymore and it’s just quicker to re-install or re-image. Because of this, and many other reasons, Linux and I parted ways some years ago and I’ve never looked back. Now here I am with a tiny little Linux box that could possibly become a big part of my job/career/life, and forgiveness is not in Linux’s nature.

So what have I done so far.

As soon as I had my Pi in hand I got a hold of a breakout cable, breadboard and some LEDs. After having already become reasonably proficient with Python I was desperate to try out the GPIO programming. Within just a few minutes I had a single LED blinking on an off. Then I plugged in two more LEDs and programmed a traffic light. Now after how ever many weeks I have upgraded to 8 LEDs and have it cycling randomly through a growing set of blinking sequences. One of which is programmable. Programming these lights became a daily kata for a while. When I took a break from a larger project I’d spend an hour programming another sequence.

I got Raspbmc set up and working across the school network. It was a challenge and while it’s functional it is unstable to say the least. It works well enough, I hope, that a teacher might be able to use it but I’m going to need to do a lot more testing first.

To date I’ve re-imaged my Pi 9 times. Three due to a suspected corrupted SD card and the rest due, mostly, to various experiments and testing that I’ve been doing.

What have I learned?

NOOBS is great but raw images are better. I’ve always found this to be the case with Linux. These one size fits all solutions that are constantly on offer are never the best solution.

Power is everything to the Pi, power it from a proper mains adaptor whenever possible. A shortage of power can result all sorts of problems, none of which are indicative of low power levels.

A 4GB SD card is not big enough. I have a 4GB card and and 8GB card. As soon as I get the OS up and running on the 4GB I’m immediately up against the wall space wise. Using the raw image really helps as the NOOBS image isn’t taking up space somewhere but it’s not enough. As soon as I install a larger package, such as Open Office, I find myself running out of space. On the 8GB card, I have NOOBS and to distros installed and space hasn’t become an issue yet.

Where do I go from here?

I’m trying to keep the purchases to a minimum being that is isn’t actually my Pi, so most of my planned projects are software based. I’m going to eventually purchase my own Pi at which point

My compulsion towards configuration is greatly eased by the compactness of Raspbian. Re-imaging is now a ten minute process where as before it could be hours.

The ICT department and I are looking at starting an after school club called Raspberry Jam. Where we’re going to test out some of the new curriculum stuff for next year on the attendees. If things go well then we’re going to embark on a project, perhaps involving a quadracopter.