Thursday, April 28, 2011

High School Algebra in Latin America

I'm grossly generalizing here in the title of this post, I will mostly discuss about my own experience as a high school student in Ecuador. But as I have read from several sources, some of these things indeed apply to lots of places in Latin America. That being said, I will keep the title.

If you come from one of the spanish-speaking countries in Latin America, you might with high probability recognize the book cover in this blog post. This is what used to be and is the synonym for algebra for most high school students in those regions. If you don't recognize this image, be it because you're not from Latin America or you really didn't know about it, then I would really like to know what's the standard book used in your country for learning algebra. This book is so pervasive in lots of places in Latin America that the word Algebra and Baldor and the picture of the guy with the turbant all come together to people's mind when the word 'algebra' is uttered.

What most people don't know is that Baldor was a Cuban mathematician who later emigrated to the United States and not the guy with the turbant depicted on the book cover. I couldn't find much information about his education in mathematics or other published material from him but he held a teaching position in the United States later in life, although the book was already being distributed from Mexico at the time. I believe one of the reasons for the adoption of his book was the lack of mathematics textbooks in Spanish at the time. But mainly because this is also a good book and if it has any flaws I believe those are the same flaws that books in other languages might have and I will refer to this in the following paragraphs.

One thing that I particularly like about this book is that it's well organized and easy to follow, I would say even easy to follow on your own. One thing I don't like is that most of the exercises are repetitive and easy, even sometimes boring. One thing that I like is that every few pages it has short biographies for every major mathematician in history. This is probably the first book where students get to know who are Laplace, Euler, Descartes, Newton, Fermat, etc. Guys who you will keep on hearing from, especially if you go into the hard sciences later in college.

Finally I will quote something said by the great physicist Richard Feynman in his interview with the BBC and which I think illustrates a criticism that applies to this book as well as to books in other languages regarding teaching science:

"I learnt algebra fortunately by not going to school and knowing the whole idea was to find out what x was and it didn't make any difference how you did it, there's no such thing as, you know, you do it by arithmetic, you do it by algebra, that was a false thing that they had invented in schools so that the children who have to study algebra can all pass it. They had invented a set of rules which if you followed them without thinking could produce the answer: subtract 7 from both sides, if you have a multiplier divide both sides by the multiplier and so on, and a series of steps by which you could get the answer if you didn't understand what you were trying to do."

I think this applies to this textbook and I highly doubt Prof. Feynman was ever in touch with our legendary Baldor's Algebra. Sadly, this is just the way Algebra is being taught in schools in general: learn the rules and get me the results.

Related Links, Sources:
Richard Feynman's interview
Aurelio Baldor's wikipedia entry

Update (April 30, 2011):
I just want to clarify that even though I mention this Baldor Algebra book was adopted maybe because it was a good book giving the standards of the time and available books in Spanish, I also state that it's too easy and boring and even if it was more difficult then it would still fall in the mistakes other books fall, just teaching calculations and rules and not the beauty of math. The idea is better pictured in the following video, this is a TED Talk by Conrad Wolfram on his view of teaching math.
http://www.ted.com/talks/conrad_wolfram_teaching_kids_real_math_with_computers.html
(Thanks @sergioroa from DFKI - Germany for sending the link)

Sunday, April 10, 2011

Minesweeper as an Introduction to Computer Science

The very first computer game that I remember playing is Minesweeper, in spanish Buscaminas (literally translates as Minefinder). It was probably 1997 during one day I was visiting the workplace of my father, I started exploring a computer with Windows 95. I think my father had loosely explained to me some of the basics about computers but I think it was mainly my experience with video games that made the transition smooth. I quickly navigated through the task bar looking for games and ended up clicking on the salient smiley face icon. I randomly clicked through the cells and ended up losing the game quickly and with disappointment. I had to wait some 3 years later until my family could finally acquire a personal computer for our house.

I liked minesweeper very much and I want to explain here how I embraced it in my education and what are the things I believe we can learn from such game that according to Wikipedia has been there since the early mainframes in the 60's. The first thing I liked about the game is that it is very self contained, it's more exciting if you figure out the game rules by yourself while trying it. You will quickly realize what are the meanings of the numbers when you start uncovering cells: The number of bombs around that cell. Then you will start realizing how to use this information and start finding patterns: The 1's in the corners, the 2's in the corners, several combinations of 2's and 3's and so on, those patterns that allow you to become faster and really master the game. Shortly after I started playing, my father and sister also liked the game and started playing it, often challenging ourselves in our computer.

After some time and with lots of spare time and a computer at home, I started exploring some basic programming. What I was actually most interested was in learning how to create webpages but at some point I found myself with programming some Javascript, mostly to open the infamous popup windows and creating some more stylish navigation menus. But I also started to wonder how to encode the rules of a game like minesweeper and thought maybe it would be a good exercise to try. I couldn't do it at the time and in my naive attempts without any guidance other than Yahoo Search and Altavista and the less known newcomer Google, I tried to learn the Pascal programming language to do the job but honestly I couldn't get very far on my own. I had to wait another 2 or 3 years until I was in my second year of college.

So I'm talking now about 2004, after an introduction to programming class and a data structures class under my belt. I was enrolled in the 'Object Oriented' programming class, a still hot topic at the time, at least in the local tech community back there. So I set my mind that I would use this class as an opportunity to implement minesweeper and play around with the rules of the game to create some variants of the basic game. The basic game requires an understanding of several things, there are two obvious things that you will gain from the experience:

1. Be good at manipulating arrays/matrices: Obvious! The game even looks like a matrix so this is the data structure you will need. You will have to traverse the matrix up and down, forward and backwards in every way possible. I implemented this in Java so I didn't need to think about dynamic allocation of arrays explicitly but if you want your game dimensions to be variable (beginner, medium, expert), then in a language like C you will want to go dynamic.

2. Be good at using recursion: This might not be too obvious but uncovering a cell with no number and no mine requires propagating a recursion call in several directions until you find a numbered cell. There's always a way to do it without recursion but recursion just comes naturally.

Beyond these two things you can learn about the power of random number generation when you're writing the routine to place the mines and also a basic convolution-like operation when you're assigning the numbers to the cells after the placement of the mines. Also if you're really into it you will notice things from the Windows Minesweeper like the fact that you never hit a bomb in your first move.

In the realm of Object Oriented programming itself which was the excuse for getting into this project, you can also learn to encapsulate your objects so well as to have the ability to create a new game by instantiating a Minesweeper class. Things like: new Minesweeper(), new Minesweeper('expert'), new Minesweeper(width, height, mineCount). Or even more, generalize your game to add the extra features in this way: SuperMinesweeper extends Minesweeper. Which effectively addresses the whole purpose of programming with objects in mind.

Minesweeper is not the only game that I get to program when I was on my first steps in the world of programming but now that I'm usually writing code for image processing and computer vision I get to remember the first times I was traversing matrices and performing convolutions and recursion calls over rows and columns. I'm including in this post a caption of the game that looks as close as it can get to the one distributed in older Windows versions. The code I wrote back then is still fully working but nowadays you can find lots of minesweeper implementations out there, even in Javascript which needs you to install nothing, you can try this one. Indeed you can find so many variants of it online and from so many places around the world. I, for one, thank all the programmers who wrote the early versions of minesweeper and also Microsoft's decision to include this nice game in his most popular software. This is a game that I believe has truly inspired many people even so far as to somebody proving that Minesweeper is NP-complete! How cool is that?