16
Aug 09
Hacking the 24 Game
A 24 Game card



You certainly know the popular 24 Game, in which you're given four 1 to 9 numbers and the objective is to come up with some combination of arithmetic operations that will end up using all the numbers and which the result is 24. In my country there are (or used to be) some serious tournaments around it and I had the chance to reach a regional stage of the national tournament when I was in my 6th grade. However, my school didn't had that much cards so my training was limited because no matter how good you are at math the memory part of the brain will always reach the solution to a puzzle before the arithmetic part does a single operation, so having less cards means less memorization/training.

So recently, as my brother now reaches that level I just thought I could put in practice my programming skills (which would have been very helpful if I had them back then) and generate all the possible cards for that game. The program returns exactly 195 390 unique cards and presents the way of solving (there could be others). Just take it, memorize it and do your best if there are some tournaments you can participate in.

Click to browse all the cards

EDIT: My friend Pedro Diogo (many thanks to him) took the data and created ready to print cards. So,

Click here to download the ready to print cards.

 

If you want to check out the code feel free to here.


Go to Blog

Comments

Alcides Fonseca 17 of August of 2009
First of all, you have written your code in C++ which I find a poor choice for this kind of quick script. A dynamic language like Ruby or Python would have been produced a more clean resulting code, and in less time (supposing you already knew it barely)

Regarding that game, I lost against the national winner and his trick was exactly that, he just memorized the cards and how to solve them. The only card he lost, was one he couldn't remember and i had my chance to think for a while (which he didn't). Later he told me in his school they would be memorizing cards all the time, even in classes. I just don't get the fun of it anymore :(
Pedro Diogo 17 of August of 2009
Ah! The nostalgia!

I did too participate on a competition before, but from what I remember some numbers where higher than 9 and some cards had square roots and fractions.

One thing that could be fun is pick up all these results, and using some graphic library, create real carts, that could be printed.
Miguel Pais 17 of August of 2009
@Pedro Diogo

That was the version for the 7th, 8th and 9th grades... this was the version for the 5th and 6th grades.

@Alcides Fonseca

You use the language you're most proficient at for solving the problems you want to solve. For me in C++ was quick. Although I know some Ruby I would potentially take more time to get the code done.

Anyway, I'm surprised you actually managed National level with just mathematical skills, I thought that was impossible.
Franciso Santos 03 of September of 2009
@Miguel Pais

He didn't say he reached National level, he just said he played against the national champion.
Pedro Borges 29 of September of 2009
Your program has an error. The solution (2 + 2) * (3 + 3) is not listed I believe.
Miguel Pais 29 of September of 2009
Yes, you're right... I didn't count with enforced priorities.

Anyway, I'll rewrite the Ruby version to add it.
FredRF 24 of May of 2010
Hy,

I think this piece of script is very useful, for those who want to figure the 24 game.

However, I guess that the way you (we) are able to come up with solutions like these is because we didn't have the solutions at hand and had to figure everything out, thus developing our brains and our thinking process...

Just...commenting!

BTW, yeah...I wish I had that on my 5th / 6th grade...

Add your thoughts about it!