4 ms·
Challenge HN: math game
spent a lot of time writing this, sorry for bad english, not a native tongue speaker.
the purpose of this game is obtaining 100 as result of various math operations following some rules
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
2) every basic math operation (+ - * /) might be used
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)
4) parenthesis might be used
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)
7) you can't juxtaposition (put together without operations/functions in between) digits (example: 78 is incorrect)
---
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
2) Multiple Occurences (MO): how many times operation/functions are used - the minimum should be 13.
3) Max Repetition (MR): the number of time the most used operation/function is used - the minimum should be 2.
You should maximize SO and minimize MO and MR
For the chart the first index that will be valued is SO, then MO and finally MR.
---
here's an example (it'd be correct if it had 100 as final result):
8 * (7+5) + 0 * (3+1) + (2+9+6) * 4
= 8 * 35 + 0 + 17 * 4
= 280 + 68 = 348
SO: * and + = 2
MO: 3 * and 6 + = 9
MR: + is used 6 times = 6
---
to submit the solution you should calculate your own indexes and final result like i did in the example.
- mattmiller 16y agoYou 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 16y agoew thanks, i actually removed rule 6)
- tansey 16y agoCan 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 16y agoas 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
- Rhapso 16y ago(((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 16y agoi 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 16y agothe 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
- deleted 16y ago[deleted]
- rick_2047 16y agoI 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 16y agoyes it is, poor indexes but it is ok :)
- paolomaffei 16y ago5! – 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