How many ways to combine the 5 cards with four arithmetic operations? There are 120 permutations of the cards and 256 sets of operations. For each of those combinations we have 14 ways to placing parenthese (14 RPN stacks) to wit: x1 @ ( x2 # ( x3 $ ( x4 % x5 ))) x1 @ ( x2 # (( x3 $ x4 ) % x5 )) x1 @ (( x2 # x3 ) $ ( x4 % x5 )) x1 @ (( x2 # ( x3 $ x4 )) % x5 ) x1 @ ((( x2 # x3 ) $ x4 ) % x5 ) ( x1 @ x2 ) # ( x3 $ ( x4 % x5 )) ( x1 @ x2 ) # (( x3 $ x4 ) % x5 ) ( x1 @ ( x2 # x3 )) $ ( x4 % x5 ) ( x1 @ ( x2 # ( x3 $ x4 ))) % x5 ( x1 @ (( x2 # x3 ) $ x4 )) % x5 (( x1 @ x2 ) # x3 ) $ ( x4 % x5 ) (( x1 @ x2 ) # ( x3 $ x4 )) % x5 (( x1 @ ( x2 # x3 )) $ x4 ) % x5 ((( x1 @ x2 ) # x3 ) $ x4 ) % x5 Study minimal numbers of divisions needed to get all possible answers. Template: x1 @ ( x2 # ( x3 $ ( x4 % x5 ))) x1 @ ( x2 # (( x3 $ x4 ) % x5 )) x1 @ (( x2 # x3 ) $ ( x4 % x5 )) x1 @ (( x2 # ( x3 $ x4 )) % x5 ) x1 @ ((( x2 # x3 ) $ x4 ) % x5 ) ( x1 @ x2 ) # ( x3 $ ( x4 % x5 )) ( x1 @ x2 ) # (( x3 $ x4 ) % x5 ) ( x1 @ ( x2 # x3 )) $ ( x4 % x5 ) ( x1 @ ( x2 # ( x3 $ x4 ))) % x5 ( x1 @ (( x2 # x3 ) $ x4 )) % x5 (( x1 @ x2 ) # x3 ) $ ( x4 % x5 ) (( x1 @ x2 ) # ( x3 $ x4 )) % x5 (( x1 @ ( x2 # x3 )) $ x4 ) % x5 ((( x1 @ x2 ) # x3 ) $ x4 ) % x5 This gives about 120*3500, or about 420,000 combinations to check. Now, not all these combinations are distinct or valid. By the rules it is necessary that at each stage the computations stay integral. They need also stay non-negative but we have Theorem: if a combination exists to produce n then a modified combination produces |n|. In particular, if we can find a combination which produces N then we can find one whose intermediate results are nonnegative so in the future we will not be concerned (much) about signs. To what extent are the combinations distinct. There are two classes of overlap: (1) combinations for which f(x1,...,x5)=f(x_sigma(1)...) for some sigma in S_5 and (2) combinations for which f1=f2 op sigma for some other f2. We week to avoid the latter by considering only those combinations which are in some sense minimal. The idea is to show that every combination can be recast as one which is "smaller" unless it satisfies these minimality conditions. (Warning: for more than 5 cards I haven't checked that these "reductions" are not circular!) Given an expression, (1) reduce the no of /'s using (a/b)/c=(a*c)/b etc. (2) cast a*(b/c) and (b/c)*a as (a*b)/c (including complex a or b or c) (3) cast a*b as b*a if b is simpler than a. (3a) cast a*(b*c)=(a*b)*c (4) cast (a*b)*c as (a*c)*b if c simpler than a. (5) (interpret the above also to favor (a-b)*(c+d) over (c-d)*(a+b) etc.) (6) do likewise with +- instead of */ (7) avoid a-b if b contains a negative: a-(b-c)=(a+c)-b; a-(b*c)=b'*c+a; a-(b+c)=(b'+a)-c (8) cast (a-b)*(c-d) as (b-a)*(d-c) if a simpler than b, or c simpler than d. This reduces the number of expressions which require 2+ /'s to only: (here +- is + or -; @ is *+-) those really requiring 3 / and a +- are only (( x1 / x2 ) +- ( x3 / x4 )) / x5 or its reciprocal x1 / (( x2 / x3 ) +- ( x4 / x5 )) those requiring two / and allowing a * are ( x1 / x2 ) +- (( x3 * x4 ) / x5 ) (( x1 * x2 ) / x3 ) +- ( x4 / x5 ) ( x1 / ( x2 * x3 )) +- ( x4 / x5 ) ( x1 / x2 ) +- ( x3 / ( x4 * x5 )) ( x1 * x2 ) / (( x3 / x4 ) +- x5 ) ( x1 * x2 ) / ( x3 +- ( x4 / x5 )) x1 * (( x2 / x3 ) +- ( x4 / x5 )) x1 / ( x2 * (( x3 / x4 ) +- x5 )) x1 / (( x2 * x3 ) +- ( x4 / x5 )) x1 / ( x2 * ( x3 +- ( x4 / x5 ))) x1 / (( x2 / x3 ) +- ( x4 * x5 )) x1 / ( x2 +- (( x3 * x4 ) / x5 )) x1 / (( x2 / ( x3 * x4 )) +- x5 ) x1 / ( x2 +- ( x3 / ( x4 * x5 ))) x1 / ((( x2 * x3 ) / x4 ) +- x5 ) ( x1 +- ( x2 / x3 )) / ( x4 * x5 ) (( x1 / x2 ) +- x3 ) / ( x4 * x5 ) ( x1 +- (( x2 * x3 ) / x4 )) / x5 ((( x1 * x2 ) / x3 ) +- x4 ) / x5 ( x1 +- ( x2 / ( x3 * x4 ))) / x5 (( x1 / ( x2 * x3 )) +- x4 ) / x5 ( x1 * (( x2 / x3 ) +- x4 )) / x5 ( x1 * ( x2 +- ( x3 / x4 ))) / x5 (( x1 * x2 ) +- ( x3 / x4 )) / x5 (( x1 / x2 ) +- ( x3 * x4 )) / x5 Additive forms of the above: ( x1 / x2 ) +- ( x3 / ( x4 +- x5 )) ( x1 / ( x2 +- x3 )) +- ( x4 / x5 ) (( x1 +- x2 ) / x3 ) +- ( x4 / x5 ) ( x1 / x2 ) +- (( x3 +- x4 ) / x5 ) (( x1 / x2 ) +- x3 ) / ( x4 +- x5 ) ( x1 +- ( x2 / x3 )) / ( x4 +- x5 ) ( x1 +- x2 ) / ( x3 +- ( x4 / x5 )) ( x1 +- x2 ) / (( x3 / x4 ) +- x5 ) x1 / (( x2 / x3 ) +- ( x4 +- x5 )) x1 / (( x2 / ( x3 +- x4 )) +- x5 ) x1 / ( x2 +- ( x3 / ( x4 +- x5 ))) x1 / ((( x2 +- x3 ) / x4 ) +- x5 ) x1 / ( x2 +- (( x3 / x4 ) +- x5 )) x1 +- (( x2 / x3 ) +- ( x4 / x5 )) x1 / ( x2 +- (( x3 +- x4 ) / x5 )) x1 / (( x2 +- x3 ) +- ( x4 / x5 )) x1 / ( x2 +- ( x3 +- ( x4 / x5 ))) ((( x1 +- x2 ) / x3 ) +- x4 ) / x5 ( x1 +- (( x2 +- x3 ) / x4 )) / x5 (( x1 / ( x2 +- x3 )) +- x4 ) / x5 ( x1 +- ( x2 / ( x3 +- x4 ))) / x5 Those that only arise with +-'s in both other spots: up to sign, they are x1 / ((+-( x2 / x3 ) +- x4 ) +- x5 ) ((+-( x1 / x2 ) +- x3 ) +- x4 ) / x5 +-( x1 / ( x2 +- ( x3 / x4 ))) +- x5 ((+-( x1 / x2 ) +- x3 ) / x4 ) +- x5 +-( x1 / x2 ) +- ( x3 / x4 ) +- x5 Summary 3 /, 1 +- 2 2/, 1*, 1 +- 24 2/, 2 +- 34 1/, 3* 1/, 2*, 1 +- 1/, 1*, 2+- 1/, 3+- 4* 3* 1+- 2* 2 +- 1* 3+- 4+- (31 combinations -- skip parentheses) The grand total comes to exactly 500 formulae. Evaluating for [pi, pi^3, pi^9, e, e^3] for all the 120 permutations shows fewer than 60000 distinct values. Some are within 10^-12 (percentage): Each of these 10 values appears 2x on the list of 60000. Each pair differs by just about 0.000000000001% (Need to update grouping information therefore) 20.0855335241758258822 20.0855335241958188564 0 0 0 3 0 2 0 4 1 0 0 0 3 1 0 4 0 2 20.085533982171000436 20.0855339821909934102 0 0 0 3 0 2 0 4 1 0 0 0 3 1 0 4 0 2 20.0855398641843420692 20.0855398642043350434 0 0 0 0 3 1 0 4 1 0 0 0 0 3 2 0 4 1 20.085540322179516623 20.0855403221995095972 0 0 0 0 3 1 0 4 1 0 0 0 0 3 2 0 4 1 -20.0855339821909934102 -20.085533982171000436 0 0 0 0 3 1 0 4 2 0 0 0 0 3 2 0 4 2 All the 60000 values are stored in four files lo midlo midhi hi. Warning: am checking for 10^-10 fractional changes and changes in formulae. It could be that there exists a formula for which |f1(x)-f1(sigma)x)|/f1(x) is less than 10^-10 but really non-zero. It could also be that f2(sigma x) equals f2(x) but appeared different in this computation for roudoff reasons, so these would look equal. Checking for distinct values (and catching the 5 pairs above) shows that there are 27141 distinct outputs possible. Some repeat according to the size of the inertial subgroup of S_5: {1}: 9000 times (e.g. (e/d-c/b)/a ) Z_2: 13557 times ( e/((d.c+b).a) ) Z_4 or Z_2^2: 3211 times (e/((d+c).b.a) ) S_3: 920 times (e-d)/(c.b.a) D_8: 180 times e/((d+c).(b+a)) (12):220 times (e+d)/(c.b.a) must be A_4, right? (24) 50 times (e/(d.c.b.a) ) has to be S_4, right? S_5: twice (e+d+c+b+a and product) Oh well that onlyl comes to 27141. Of course for positive integers with _integer_ outputs there are fewer outputs (but I think there may be integer inputs with 27141 integer outputs, no?) There are fewer outpus yet if you insist on _positive_ outputs. I have gotten numbers like 1000-1500 of different outputs. Howw many of these outputs are in [1,25]? few -- it appears the number of times an integer in this range shows up is in the tens or hundred usually (out of a possible 27141). I have not spotted any outputs that occur only once (a hard game!) but outputs that occur zero times (an impossible game!) seem to be occuring about once every 500 games now that I have the permutation generator fixed. Here it is! 13=1,5,8,14,19=(((19-1)*5)+14)/8, unique solution, took 118 permutations. Some impossible ones found with buggy routines (they _are_ impossible but the timings are unreliable -- improved shuffling shows some "solved" cases may not have been!). {19|1,1,14,15,23} {13|5 5 5 19 22} {19|1,11,11,23,24} {15|10,10,10,11,21} {24|8,17,17,22,23} {6|10 10 17 24 25} The following rounds were solved but tough: 16 | 1, 11, 12, 12, 22 took 28 permutations for success. {12|5,6,16,21,22} took 57 The pseudo-game 43|1, 22, 6, 10, 10 took until the 115th permutation (it's (10-1)*22/6 + 10 = 43, and probably that's the only formula that works) ================================================================ Some new impossibles generated with new version: 0454:21|10 10 11 11 17 0235:12| 6 9 19 20 22 0240: 5| 5 13 16 19 24 0528:13|15 7 21 12 15 0657: 7|16 25 7 20 8 0418: 1| 1 10 16 12 21 0002:25|11,9,10,1,11 1390:25| 4 5 13 17 17 0485:13| 1 4 10 13 23 0901: 6|20 23 6 6 22 Files: ops500.cpt is a list of all the 500 formulas in a form that can be inputted directly. moo.ub is an experimental version of kry500.ub. (encodes some potiential routines.) kry[xxx].ub is a version of krypto using the reductions to [xxx] formulae; latest version is kry500.ub NOTEPAD: on 92d permutation get two of four formulae (22-20)*11)-(13/13)=21 {10 14 14 16 23}-> 1(12 solutions)( permutations needed) 5(12) 7(8) 9(2)(32): 14-(((23-16)*10/14) is unique 19(6) 24(4)(34): (((14+23)*10+14)/16 is unique. {1,9,13,16,17} -> 1(4) 17(4)