Twenty Four, Again: Difference between revisions
Jump to navigation
Jump to search
imported>Kmk21 Created page with "there are only 4! permutations of the numbers. There are only 4^3 combinations of operators. There are only 10 combinations of parenthesis. (xx)xx x(xx)x xx(xx) (xxx)x ((xx..." |
imported>Kmk21 No edit summary |
||
Line 5: | Line 5: | ||
There are only 10 combinations of parenthesis. | There are only 10 combinations of parenthesis. | ||
(xx)xx | (xx)xx | ||
x(xx)x | x(xx)x | ||
xx(xx) | xx(xx) | ||
(xxx)x | (xxx)x |
Revision as of 02:43, 2 November 2017
there are only 4! permutations of the numbers.
There are only 4^3 combinations of operators.
There are only 10 combinations of parenthesis.
(xx)xx x(xx)x xx(xx) (xxx)x ((xx)x)x (x(xx))x x(xxx) x((xx)x) x(x(xx)) (xx)(xx)
4! * 4^3*10 = 15360
Just iterate through all of them and find the cheapest.
One of the challenges to this problem SHOULD be to actually evaluate the expression...they want you to use a recursive descent parser (which you SHOULD know how to build....), but you can just dump it in java's javascript engine and call "evaluate" which will evaluate the string-based expression for you.