

Challenge HN: math game - paolomaffei

spent a lot of time writing this, sorry for bad english, not a native tongue speaker.<p>the purpose of this game is obtaining 100 as result of various math operations following some rules<p>1) every digit from 0 to 9 (0 1 2 3 4 5 6 7 8 9) included must be used once and only once in the expression<p>2) every basic math operation (+ - * /) might be used<p>3) these math functions might be used:
-power: x^y
-square root: sqrt(x)
-cube root: cbrt(x)
-factorial: x! (for example 4! = 4 * 3 * 2 * 1)
-summation from 1 to x: S(x) (for example S(4) = 4+3+2+1)<p>4) parenthesis might be used<p>5) the 0 must be useful to obtain the final result of 100; if the 0 is removed from the expression and the final result doesn't change then the expression is unacceptable (example: expression + 0)<p>7) you can't juxtaposition (put together without operations/functions in between) digits (example: 78 is incorrect)<p>---<p>to value quality of solutions we'll use 3 indexes:
1) Single Occurences (SO): how many different operations/functions are used - the maximum is 9 of course<p>2) Multiple Occurences (MO): how many times operation/functions are used - the minimum should be 13.<p>3) Max Repetition (MR): the number of time the most used operation/function is used - the minimum should be 2.<p>You should maximize SO and minimize MO and MR<p>For the chart the first index that will be valued is SO, then MO and finally MR.<p>---<p>here's an example (it'd be correct if it had 100 as final result):<p>8 * (7+5) + 0 * (3+1) + (2+9+6) * 4
= 8 * 35 + 0 + 17 * 4
= 280 + 68 = 348<p>SO: * and + = 2<p>MO: 3 * and 6 + = 9<p>MR: + is used 6 times = 6<p>---<p>to submit the solution you should calculate your own indexes and final result like i did in the example.
======
Rhapso
(((7^4)-1)/(2 _(3+9))+0!(5+sqrt(cbrt(sqrt(...8...))))/(S(S(..6..)))

I used an infinite number of square roots, cube roots, and sums. None of the
rules require a finite expression :P

SO: ^ + - _ / sqrt cbrt S= 9

MO: infinite

MR: infinite

~~~
paolomaffei
i guess it's valid (as long as the result is really 100, you haven't provided
calculations). but it's not the best avalaible, since doing MO 13 is actually
easy

~~~
Rhapso
the end works out zero. lim (6)^(1/n) == 1 n -> inf

The second one is a bit tricky, SUM(N){1 to inf} == inf thus: 1*(5+1)/inf == 0

------
mattmiller
You example is illegal. The operation 3+1 can be removed without changing the
answer, violating rule 6. You should replace rule 5 and 6 with "Zero can only
be used in power (as y) and factorial operations".

~~~
paolomaffei
ew thanks, i actually removed rule 6)

------
tansey
Can we assume only operators that return integers are valid? For instance, you
can't do sqrt(2) factorial, but you can do sqrt(4) factorial. Kind of tricky
when dealing with things like 2 * (3/6) though.

~~~
paolomaffei
as long as the result is 100 i'm fine with it, im not sure if you can still do
100 when you dont have an integer, i'd say why not

------
paolomaffei
5! – S(6) + sqrt(9) – (cbrt(8) * (2^3)/4) / (7^0 + 1)

120 – 21 + 3 – (2*2/2) = 100

SO: 9 MO: 13 MR: 2

------
rick_2047
I don't know if this is legal by rules but here my solution goes:

    
    
      9*5+(6*(7+2))+(1+4+3+8)^0
      =45+(6*9)+1
      =45+54+1
      =100

~~~
paolomaffei
yes it is, poor indexes but it is ok :)

