# help with number calculation algorithm [hw]

Filed under:
|
|
|
##### homework

Hi -

I'm working on a hw problem that asks me this:

given a finite set of numbers, and a target number, find if the set can be used to calculate the target number using basic math operations (add, sub, mult, div) and using each number in the set exactly once (so I need to exhaust the set). This has to be done with recursion.

So, for example, if I have the set

``````{1, 2, 3, 4}
``````

and target 10, then I could get to it by using

``````((3 * 4) - 2)/1 = 10.
``````

I'm trying to phrase the algorithm in pseudo-code, but so far haven't gotten too far. I'm thinking graphs are the way to go, but would definitely appreciate help on this. thanks.

© Stack Overflow or respective owner

### Related posts about algorithm

• #### Jpeg Algorithm vs BMP Algorithm?

as seen on Super User - Search for 'Super User'
I'm just wonder, what the differences are between creating a BMP file algorithm and JPG file algorithm ? If you know the others images' format algorithm, please post them. Thanks. >>> More

• #### word disambiguation algorithm (Lesk algorithm)

as seen on Stack Overflow - Search for 'Stack Overflow'
Hii.. Can anybody help me to find an algorithm in Java code to find synonyms of a search word based on the context and I want to implement the algorithm with WordNet database. For example, "I am running a Java program". From the context, I want to find the synonyms for the word "running", but the… >>> More

• #### Search algorithm (with a sort algorithm already implemented)

as seen on Stack Overflow - Search for 'Stack Overflow'
Hello, Im doing a Java application and Im facing some doubts in which concerns performance. I have a PriorityQueue which guarantees me the element removed is the one with greater priority. That PriorityQueue has instances of class Event (which implements Comparable interface). Each Event is associated… >>> More

• #### Is there any algorithm for finding LINES by PIXEL COLORS on picture?

as seen on Stack Overflow - Search for 'Stack Overflow'
So I have Image like this I want to get something like this (I hevent drawn all lines I want but I hope you can get my idea) I need algorithm for finding all straight lines on it by just reading colors of pixels. No hard math, no Haar, no Hough. Some algorithm which would be based on points… >>> More

• #### collsion issues with quadtree [on hold]

as seen on Game Development - Search for 'Game Development'
So i implemented a Quad tree in Java for my 2D game and everything works fine except for when i run my collision detection algorithm, which checks if a object has hit another object and which side it hit.My problem is 80% of the time the collision algorithm works but sometimes the objects just go… >>> More

### Related posts about numbers

• #### read numbers from files in columns, one column whole numbers, other column numbers with decimals

as seen on Stack Overflow - Search for 'Stack Overflow'
int price=' '; // attempt to grab a decimal number - but not the correct way int itemnum=' '; // attempt to grab a whole number - but not the right way while((price== (price*1.00)) && (itemnum == (itemnum*1))) What is a way to get numbers in 2 diff columns where one column is whole numbers… >>> More

• #### C code won't compile

as seen on Stack Overflow - Search for 'Stack Overflow'
Please help me to understand why the following code will not compile: #include <stdio.h> //#include <iostream> //using namespace std; int main(void){ int i,k,x,y,run,e,r,s,m,count=0; char numbers[19][19]; for(i=0;i<19;i++){ for (k=0;k<19;k++){ numbers[i][k]='… >>> More

• #### Regex : Matching phone numbers starting with NNN and having 10 numbers

as seen on Stack Overflow - Search for 'Stack Overflow'
I need to match phone numbers that : start with 010 or 012 or 016 or 019 Consist of 10 numbers exactly can you please help me on how to match numbers using PHP and regex thanks >>> More

• #### How to convert sequence of numbers in an array to range of numbers

as seen on Stack Overflow - Search for 'Stack Overflow'
In javascript how to convert sequence of numbers in an array to range of numbers? eg. [2,3,4,5,10,18,19,20] to [2-5,10,18-20] >>> More

• #### program to print odd numbers and even numbers on seperate threads

as seen on Stack Overflow - Search for 'Stack Overflow'
Hi, I am learning programming using pthreads. How can I write a program to print odd numbers and even numbers on separate threads. >>> More