Finding integer numbers using basic operations

  • Thread starter seezeey
  • Start date
  • #1
1
0

Main Question or Discussion Point

Hello everyone!

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
 

Answers and Replies

  • #2
12,945
9,602
You have a certain alphabet, n integers combined with at least one of four possible operation symbols. Then you have an evaluation function: the calculation of the expression. Thus we have a finite number of allowed words with a finite set of evaluation values. These can all be listed and then decided, whether a given number is among them.

As such an algorithm is completely useless from a scientific point of view, there probably won't be any approaches other than brute force.
 

Related Threads on Finding integer numbers using basic operations

  • Last Post
Replies
3
Views
6K
  • Last Post
Replies
9
Views
3K
Replies
5
Views
3K
Replies
12
Views
3K
  • Last Post
Replies
16
Views
5K
Replies
8
Views
7K
Replies
21
Views
3K
Replies
2
Views
10K
  • Last Post
Replies
6
Views
2K
  • Last Post
Replies
2
Views
2K
Top