- #1

seezeey

- 1

- 0

I am trying to construct an algorithm for the following problem and was wondering if there is any existing body of knowledge on this. Please forgive me if this is inappropriate (or ridiculous) but I am totally foreign to number theory.

It goes like this:

You are given n integers and allowed to use four basic operations. You are also given another integer as the target. You are required to find the target using the given numbers.

The only rule is that you can use each number (given or derived) only once.

Is there an efficient algorithm to check if there exists a solution to any given instance of this problem?

For example:

given numbers: 1 2 3 4

target: 17

a valid solution would be (4 + 1) * 3 + 2 = 17

an invalid solution would be (4 + 4) * 2 + 1 = 17, since 4 is used twice.

My solution is practically a brute-force approach with pruning and it is subject to state-explosion.

Thanks in advance...

--seezeey