From: Dan Zwell Date: 2007-08-26T03:47:35+09:00 Subject: Re: Combinations of numbers/operators? Donald Patch wrote: > One more thing: how would you get parentheses into the act if you also > wanted to override operator precedence? > > Example: > > (1/2)+(3*4) = 12.5 > 1+(2*3)-4 = 3 > ... > > Thanks!! Do you know you are only dealing with four numbers? It makes quite a difference. A general algorithm to parenthesize all possible combinations isn't that hard in principle (recursively split an array of numbers, adding an operator and parentheses at each stage), but it's awkward to code, aspecially while maintaining the "all permutations of operations" that you originally asked about.