Today we are visiting a specific instance of a well-known basic mathematics game, the 24 Game. The "24 Game" is usually played with younger students because it helps them develop skills related to the basic arithmetic operations.

A picture of a wall with a 24 in it
Photo by Kadir Celep on Unsplash

Problem statement

The "24 Game" is usually played with four different numbers from \(1\) to \(9\), for example drawn randomly out of a small deck with those numbers. For this blog post, you can forget about all that, I picked very specific numbers for you.

Using the four numbers \(3\), \(3\), \(8\) and \(8\) and the four arithmetic operations addition, subtraction, multiplication and division, you have to make an expression that evaluates to \(24\). The rules are simple:

  • each number must be used exactly once;
  • operations can be used any number of times (even zero times);
  • the precedence of operations can be changed by the use of \(()\);
  • numbers cannot be used by positioning them in a special way, e.g. you can't make \(33\) by joining the two \(3\)s and you can't make \(27\) by writing \(3^3\).

I am not giving you a puzzle with a cheap trick involved. This is pure arithmetic.

An example valid expression would be \((3+3)\times (8+8)\) except this is not the solution because it gives \(96\) instead of \(24\).

Give it some thought, maybe take out a piece of paper and a pencil.

I heard of this from the same friend who told me about the "Fold the alphabet" problem.

Hint

Do not read the hint if you haven't spent some time thinking about the problem yet!

The intermediate steps do not have to evaluate to integer numbers.

Solution

There really is no point in sugar coating this for you, the solution is the expression \(8 \div (3 - 8\div 3)\). Quite ingenious, isn't it?

[Don't forget to subscribe to the newsletter] to get bi-weekly problems sent straight to your inbox and to add your reaction below.

Become a better Python 🐍 developer 🚀

+35 chapters. +400 pages. Hundreds of examples. Over 30,000 readers!

My book “Pydon'ts” teaches you how to write elegant, expressive, and Pythonic code, to help you become a better developer. >>> Download it here 🐍🚀.

Previous Post Next Post

Blog Comments powered by Disqus.