Monday, 13 October 2008

Pink elephants, numbers, & the spaces in between...

A confession: the single hardest thing for me in trying to learn computer programming, specifically loops, is one very, very basic issue - counting.

That's right. I can't count properly.

All my life, I've had problems with the difference between numbers, and the intervals between numbers. Even though I have A's in A Level Mathematics and Further Maths, and I passed the Mensa IQ test. It just shows how meaningful test results are, eh?

1, 2, 3. That's 3 numbers. But, there are 2 steps between them. What are we talking about: how many numbers, or how many steps there are between those numbers? I always have to stop and think about that before I can carry on. The difference is not instinctive: I actually find it very confusing, and I often mix them up. Even though it's basic arithmetic.

So when I'm looking at an example of a loop, or trying to write a loop, I have to work through a couple of actual instances before I know whether it should be < or <= (less than, or less than or equal to), or if it should be > or >=, simply in order to get the correct number of repetitions.

Interestingly, I'm not alone. When I admitted this to my best friend, she told me that in fact she has exactly the same issue.

When she was 4 or 5 years old, she drove her teachers mad. They lined up cardboard pink elephants to illustrate addition and subtraction, and she just couldn't grasp that X number of elephants minus one elephant produced a particular number of remaining elephants. She was more concerned with the interval between the final elephant and the one that had just been removed - what had happened to that? What happened to the space between two objects if you took away one of them (as if the elephant were a bookend), did the space "fall out", where did the space go, doesn't the removal affect everything else? They had to tell her to shut up and stop worrying about that - just worry about the elephants!

And she felt that intervals had properties, and that numbers had "directionality" - that the interval between 2 and 1 is not the same as the interval between 1 and 2. Surely the interval between 2 and 1 isn't 1, it's minus 1. (She also wanted to know: where did the elephant that had been taken away go, what had they done with it, and why? Surely that might have an impact on the elephants that remained? But they weren't interested...)

I must admit I didn't go quite as far as all that, myself. But still I have a problem with things, and the spaces between things, and boundaries / limits - when do you count the thing itself that's at the upper or lower boundary of what you're dealing with, and when do you not.

I think that maybe my friend and I both visualise numbers as actual objects, locations in 2D (or perhaps 3D) space. I'm not sure if that's an example of us both having a kind of number form synaesthesia, or if that's just a child's way of trying to grasp abstract concepts like arithmetic by unconsciously using a number line.

Like, what happens exactly when you add and subtract? What are you doing, what are you counting? The numbers, or the spaces between them?

Does 3 - 1 = 2 means there are 2 steps between the number at location 1, and the number location 3? Is that how subtraction works?

But hang on, what about addition then? 1 + 3 = 4. How does that work, in terms of spaces between locations 1 and 3? Confusion...

Solution: aha, you're counting the number of steps away from 0 that a number is. Addition is just adding up the distance the first number is from 0, to the distance the second number is from 0. And subtraction is the difference between the two distances.

Got it. Sort of.

Oddly enough, I don't have the same sort of problem with multiplication, division etc - probably because I've just memorised the multiplication tables, 3 x 4 is 12, and that's just the way it is.

So effectively this means I've never understood the fundamental hows and whys, why things are the way they are - I've just memorized a few set things, and then I apply them; I can do that at least!

If I could just figure out exactly what I need to memorise for a basic loop - this structure gives you that type of counting / number of iterations, this other structure gives you that other type of iteration - I think I'd be there, at least for the basic stuff.

Relationships, proportions and different types of things

I have also always had a problem with relationships or proportions involving different types of things.

You know, things like, if 3 elephants are equivalent to 20 chickens, how many elephants would equate to 50 chickens? The only way I managed to get through all that (and I still have to do this today), was to be utterly mechanical about it.

I worked out a formula. You line up the "like" things (elephants) on the left, and, in the top line, you put the other thing that you know about on the right.

Known_type2 equates to Known_type1
Unknown_type2 equates to WHAT?

And then I'd know the answer was to go through 2 sides of a triangle which I'd memorised by rote: Top right x Bottom left ÷ Top left. Seriously.

20 chickens = 3 elephants.
50 chickens must be 3 x 50 ÷ 20 elephants.

If they gave me the number of elephants for the second time, I'd have to line it up differently but use the same formula, similar things on the left:

3 elephants = 20 chickens.
8 elephants must be 20 x 8 ÷ 3 (top right x bottom left ÷ top left).

To this day, I've never developed an instinctive feel for what goes with what and how you put them together.

I wonder if all this says something interesting or profound (or not!) about me and my friend compared with other people, or about the concept of numbers, or how children learn to conceptualise numbers - and if so, what on earth that would be.

Are we alone, or do other people have similar issues?

My friend of course looks at it another way. She said, when they asked her: "If it takes 3 men each using a 2.5 litre bucket X minutes to fill a pond, how long would it take 2 men using 7 litre buckets?", she thought - I really don't care; why can't they just use a hose?


Tom Morris said...

If it's just loops and iteration that are the problem, then you should consider different programing languages.

The Java/C-style for loop is not everywhere. Take Python loops as an example:

for i in range(5): print i

is equivalent to a Java-style loop of:

for (i = 0; i < 5; i++) { System.out.println(i.toString()); }

Or maybe look at the Ruby syntax:

5.times { |i| puts i.to_s }

Both the Ruby and Python syntax here move away from less-than/greater-than syntax towards the concept of "how many times does this block iterate?"

Another Ruby construction that's pretty neat:

(5..15).each { |i| puts i.to_s }

The 5..15 part instantiates a Range object - at a shell, type (5..15).to_a and you get back an array containing all the integers from 5 to 15 inclusive. The .each function creates an iterator based on that array.

Separate out the iterator or array from the numbers, and you may find the problem gets a little easier to manage.

Or use Haskell or another functional programming language - and you don't need to worry about loops. When your language copes with lists well, and when it has lambda functions and the like, you don't need to do it so often. In fact, Haskell doesn't have loops at all.

Also, the men-filling-buckets problem has a problem - it doesn't take account of the fact that a 7 litre bucket takes longer to fill than a 2.5 litre bucket but takes the same amount of time to throw into the pond. Without further information, it's not possible to know accurately.

Márcia W. said...

Why haven´t it thought about the time factor just to throw it at the teachers´faces....
Anyway, maybe my case is not synaesthesia, but I have a problem with the sequence of letters in the alphabet. I can´t "understand" for example why "o" cames before "p" when it is obvious that "p" is "stronger". Every time I have to look up a word on a dictionary I have to run part of the sequence in my head.

Improbulus said...

That sounds a lot easier Tom, but alas I have to do what I have to do.

Interesting about the o & p Marcia, maybe it is a bit of synaesthesia, the "stronger" thing...

Zoe said...

The buckets for filling the pond come ready-filled by the Maths Problem Genie, actually.