# Convert calculation string to multiple lines

**URL:** <https://forum.kirupa.com/t/convert-calculation-string-to-multiple-lines/242678>\
**Category:** flash\
**Created:** [October 29, 2007, 1:18pm UTC](https://forum.kirupa.com/t/convert-calculation-string-to-multiple-lines/242678 "2007-10-29T13:18:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![arckodrazen](https://avatars.discourse-cdn.com/v4/letter/a/e95f7d/32.png) [@arckodrazen](https://forum.kirupa.com/u/arckodrazen)\
**Post date:** [October 29, 2007, 1:18pm UTC](https://forum.kirupa.com/t/convert-calculation-string-to-multiple-lines/242678/1 "2007-10-29T13:18:17Z")

</div>

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
