TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Challenge HN: math game

4 pointsby paolomaffeialmost 15 years ago
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.

5 comments

Rhapsoalmost 15 years ago
(((7^4)-1)/(2<i>(3+9))+0!(5+sqrt(cbrt(sqrt(...8...))))/(S(S(..6..)))<p>I used an infinite number of square roots, cube roots, and sums. None of the rules require a finite expression :P<p>SO: ^ + - </i> / sqrt cbrt S= 9<p>MO: infinite<p>MR: infinite
评论 #1523818 未加载
mattmilleralmost 15 years ago
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".
评论 #1522210 未加载
tanseyalmost 15 years ago
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.
评论 #1522820 未加载
paolomaffeialmost 15 years ago
5! – S(6) + sqrt(9) – (cbrt(8) * (2^3)/4) / (7^0 + 1)<p>120 – 21 + 3 – (2*2/2) = 100<p>SO: 9 MO: 13 MR: 2
rick_2047almost 15 years ago
I don't know if this is legal by rules but here my solution goes:<p><pre><code> 9*5+(6*(7+2))+(1+4+3+8)^0 =45+(6*9)+1 =45+54+1 =100</code></pre>
评论 #1523826 未加载