Hey guys
I’m having an algorithm that solves a target value by using 6 numbers (cfr: The Count Game: user picks 6 numbers, a target value is calculated, user has to find this target by using the 6 numbers and the results of yet calculated rows).
ie: 1, 2, 3, 4, 5, 6
target: 14
my solution:
4 + 6 = 10
3 + 1 = 4
10 + 4 = 14
Ok, now that I explained this i’ll tell you what my problem is. I found a class that solves this calculation by itself (if user wants to see the solution), but it has this form:
(((((9+8)*5)-4)+1)*3) = 246
or
((((9+8)5)-4)(3-1)) = 162
how do i break this up to (only for second calulation):
9 + 8 = 17
17 * 5 = 85
85 - 4 = 81
3 - 1 = 2
81 * 2 = 162
Do I need to user regular expressions? Or Substrings? Are there regex in (maybe other languages) that solve this?
Any help appreciated!
Thanks in advance
Arcko Drazen