The $24$ game is as follows. Four numbers are drawn; the player's objective is to make $24$ from the four numbers using the four basic arithmetic operations (in any order) and parentheses however one pleases.
Consider the following generalization. Given $n+1$ numbers, determine whether the last one can be obtained from the first $n$ using elementary arithmetical operations as above. This problem admits succinct certificates so is in NP.
Is it NP-complete$?$
This is still WIP. There are a few missing details, still I think it's better than nothing. Feel free to edit in the missing details.
Given a problem of
SUBSET-SUM. We have a set ofA={a1,a2,...,an} numbers, and another numbers. The question we're seeking answer to is, whether or not there's a subset ofAwhose sum iss.I'm assuming that the 24-game allows you to use rational numbers. Even if it doesn't, I think that it is possible to emulate rational numbers up to denominator of size
pwith integers.We know that
SUBSET-SUMis NP-complete even for integers only. I think theSUBSET-SUMproblem isNP-hard even if you allow treating each ai as a negative number. That is even ifAis of the formA={a1,-a1,a2,-a2,...,an,-an}. This is still a wrinkle I need to iron out in this reduction.Obviously, if there's a subset of
Awith sums, then there's a solution to the24-problem for how to reach usingAtos. The solution is only using the+sign.The problem is, what happens if there's no solution which only uses the
+sign, but there is a solution which uses other arithmetic operations.Let us consider the following problem. Let's take a prime
pwhich is larger thann, the total number of elements inA. Given an oracle which solves the24-problem, and aSUBSET-SUMproblem ofA={a1,a2,...,an} ands. We'll ask the oracle to solve the24-problem onfor the following values:
If the solution includes multiplication, we will have a denominator larger than
pin the end result, and thus we will not be able to reach any si.Given an arithmetric expression that contains aiaj=x+(1/p2), It is impossible that the denominator p2 would "cancel" out, since there are at most
nelements in the summation, and thus the numerator would never reachp, sincep>n.THIS IS NOT QUIT RIGHT! The expression aiaj-akal will be an integer, and therefor our oracle might return answer which includes two multiplications one negative and one positive.
What about division? How can we be sure no division will occur. Find another prime
qwhich is different than p, and larger than the largest ai timesn. Multiply all answers byq. The setAwill beWe will look for the following values:
In that case, ai/aj will be smaller than the minimal element in
A, and therefor the end result which will contains ai/aj will never be one of the si we're looking for.