# Combinatorial fortytwology (5 * 270 / 32 = 42?) [Work in progress]

Created | Updated Jan 28, 2002

It is probably safe to say that the average Researcher on h2g2 enjoys looking for ways to combine the digits in his/her Researcher number, using different operators to produce the number 42. However, very few Researchers seem to have checked their 42-count. The 42-count of a number is simply how many ways one can reach 42 using the digits of said number. Although the 42-count of a number may seem interesting at first, it is in essence a measure of how high the number is. The 42-ratio, on the other hand, measures the *real* '42-ishness' of a number by dividing the 42-count by the number of legal combinations of the digits of said number. It is shown below *[Note to self: SHOW IT]* that, indeed, 42 has the highest 42-ratio.

### Reaching Level 42

As mentioned above, the idea is to combine the digits in the Researcher number. For example, Researcher number 147672 can produce 42 in the following way.

1 + 4 + 7 * 6 - 7 + 2 = 42

Note that the digits must be in the same order as in the Researcher number. The operators used above are strictly arithmetical. Concatenation is also allowed, as in the following example.

1'4 / 7 + 6 * 7 - 2 = 42

(Here, the apostrophe represents concatenation.) The next example shows how the concatenation operator is omitted, which it very often is.

14 / 7 + 6 * 7 - 2 = 42

The simplified version of the 42 game, as this process is often referred to, uses only integers and no parentheses. The complex version allows real numbers, parentheses, roots, exponents and factorials.

#### Integers or real numbers?

3 divided by 2 is 1.5, right? As the reader probably already knows, the results of certain divisions differ when we use integers. 3 divided by 2 is 1. Which system should be used? The answer is both. If we want to know exacly how '42-ish' a number really is, we need to explore all possibilities!

The problem now is how to distinguish between two different division operators. One solution is to represent real divisions with '/.', where the '.' reminds us that results can include the decimal point, and '/' represents the integer division.

1 + 4 * 76 / 7 - 2 = 42

1 + 4 * 76 /. 7 - 2 = 42.428571428571 ...^{1}

As the reader can plainly see, allowing both real and integer divisions embiggens^{2} the search space; there are now quite a lot of possibilities.

### The 42-count

*[Note to self: Explanation/intro here.]*

#### Calculating it

The most straight-forward way of calculating the 42-count of a number is to evaluate all the legal combinations of digits (in the same order as in the number) and operators. *Illegal* combinations include formulas that cause division by zero, illegal combinations of operators such as "4 + * 3", unmatched parentheses, et cetera. One rather important error is the mismatching of operands and operators. For instance, we can't include a real number in an integer division, although the converse is perfectly legal.

We can easily compute the number of different combinations, as long as each operator takes two parameters^{3}. If there are *n* digits in the number, there are *o*^{n - 1} different combinations in the simplified version of the 42 game, where *o* is the number of allowed operators.

So far, there is no way to calculate the 42-count of a number in polynomial time. In fact, it is very probable that this problem is NP-hard.

^{1}The sequence 428571 is repeated indefinitely.

^{2}A perfectly cropulent word.

^{3}The operator '-' actually only takes one parameter, ie it takes one number and returns the negative value. It is used in conjunction with addition to create subtraction, an operator that takes two parameters.

*(*

**Bad**confusing footnote!**Bad**!)