Reputation: 31
Hi i really need your help.First of all , think about we got two text files:
In numbers.txt we have:
4 5 3 2 10 1 45
In process.txt we have:
+ * /
We want to find 45 as a result with using 4 5 3 2 10 1
numbers and + * /
to do sums.
Finally we want a txt file like output.txt
4 + (5 + (3 * (2 + (10/1)))) = 45
include the solution like this.
Each number can be used for one time and each process doesn't needed to be used but we cannot use anyother that not in process.txt.
note:if we cannot find the exact result , we have to find a near value.
Can you please help me about that? I'm totaly lost about this. Sorry for my bad english.
Upvotes: 3
Views: 314
Reputation: 929
you might wanna look here Code Golf: Countdown Number Game there is no java code but you should be able to understand the idea behind
Upvotes: 0
Reputation: 8615
Homework hint: Use two Stack
s, one holds numbers, one holds operators. Examine the Stacks when adding operators, to see if you can perform any merging of numbers.
Upvotes: 3