pravinth Ganesan

Greenhorn

Posts: 13

posted 11 years ago

Hi Friends,

How can i generate all the possible Integer values with the 4 basic arithmatic operators +,-,/,* for a given sequence of integer numbers?

For example if the numbers are 2,3

Then the resultmust contain all the following values:

2+3=5

3-2=1

3/2=1

3*2=6

so the resulting array must contain 1,5,6

The number of integers can be of any number,

for example:{2,3,4,56,2,1}

and when finding a result you must you all the integers in each step.

i know for some gurus its easy.please help me!

Thank You!

How can i generate all the possible Integer values with the 4 basic arithmatic operators +,-,/,* for a given sequence of integer numbers?

For example if the numbers are 2,3

Then the resultmust contain all the following values:

2+3=5

3-2=1

3/2=1

3*2=6

so the resulting array must contain 1,5,6

The number of integers can be of any number,

for example:{2,3,4,56,2,1}

and when finding a result you must you all the integers in each step.

i know for some gurus its easy.please help me!

Thank You!

Have a nice day

posted 11 years ago

The reason a "guru" may find a problem easy is because he has considered this or similar problems before. This is why we ask that folks asking questions around here Show Some Effort. The only way to learn to write code is to write code.

So what have you done so far?

So what have you done so far?

posted 11 years ago

I'm obviously not a guru, because I don't even understand the question.

Originally posted by Joe Ess:

The reason a "guru" may find a problem easy is because he has considered this or similar problems before...

I'm obviously not a guru, because I don't even understand the question.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." *~Joe Strummer*

sscce.org

Mark Newton

Ranch Hand

Posts: 129

Barry Gaunt

Ranch Hand

Posts: 7729

posted 11 years ago

I did it, my program works! But I wrote it in the margin of a book I was reading which I unfortunately left on the train this morning...

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch

Getting someone to think and try something out is much more useful than just telling them the answer.

pravinth Ganesan

Greenhorn

Posts: 13

posted 11 years ago

Hi Mr.David, Thanks for your reply.You are right.

Its not a matter of generating same value again.

But the problem is to use all the given Integer values at a time.I mean as you specified its right for 2 integer variable-values.But for three it should be

a+b+c

a+b*c

a+b/c

a+b-c

a*b+c

a*b-c

a*b/c

a*b*c

a-b+c

a-b-c

a-b/c

a-b*c

a/b+c

a/b-c

a/b/c

a/b*c

Okay i think i can able to do it myself now.If you can then please post here your code.Thank You! Its very knid of you!Thank You!

Its not a matter of generating same value again.

But the problem is to use all the given Integer values at a time.I mean as you specified its right for 2 integer variable-values.But for three it should be

a+b+c

a+b*c

a+b/c

a+b-c

a*b+c

a*b-c

a*b/c

a*b*c

a-b+c

a-b-c

a-b/c

a-b*c

a/b+c

a/b-c

a/b/c

a/b*c

Okay i think i can able to do it myself now.If you can then please post here your code.Thank You! Its very knid of you!Thank You!

Have a nice day

Ken Blair

Ranch Hand

Posts: 1078