9
$\begingroup$

You have probably heard of code golfing? There the task is to find the shortest computer program that produces the required output. Here we want to perform math golfing - find the shortest formula that produces a given number. The length of a formula is measured as the number of characters. The format must be as follows:

  • Contain only digits '0' to '9' and characters '+' (addition), '-' (subtraction), '*' (multiplication), '^' (exponentiation), brackets '(' and ')'.
  • Digits can be concatenated such as 567.
  • Operations have precedence, like in BODMAS. Brackets are done first, followed by exponentiation, followed by multiplication, followed by addition/subtraction (from left to right).
  • For example (10^2+1)*2^5 is equivalent to (100+1)*32 = 3232. The formula uses 12 characters, so it is not a compact representation of the result that has 4 characters.

Find the shortest formulas that represent the following numbers:

  1. 99999999999
  2. 41601569625
  3. 61917364165
  4. 82644187136
  5. 33059881770
  6. 12345678901234
  7. 10101010101010
  8. 33333333333333
  9. 68945723674934237482
  10. 5782934283492912347898237400000
  11. 34828517376
$\endgroup$
  • $\begingroup$ Partial answers are accepted too! $\endgroup$ – Dmitry Kamenetsky Jun 3 at 4:49
  • 1
    $\begingroup$ "from left to right" breaks the default priority of $a^{b^c} = a^{(b^c)}$, though. $\endgroup$ – my pronoun is monicareinstate Jun 3 at 5:42
  • $\begingroup$ Is a unary minus allowed? $\endgroup$ – Jens Jun 4 at 19:48
  • $\begingroup$ Jens yeah why not. Any attempts at the missing numbers? $\endgroup$ – Dmitry Kamenetsky Jun 5 at 0:48
  • $\begingroup$ I have decided to add brackets to make things a bit more interesting, especially for those larger terms. The current answer is still valid. $\endgroup$ – Dmitry Kamenetsky Jun 5 at 2:26
6
$\begingroup$

I'm still missing a few of the answers.

99999999999 = (7 characters)

10^11-1

41601569625 = (6 characters)

3465^3

61917364165 = (8 characters)

12^10-59

82644187136 = (6 characters)

4*14^9

33059881770 = (9 characters)

3*18^8+42

12345678901234 = ?

10101010101010 = ?

33333333333333 = ?
I had an 11-character solution but that used division (10^14/3-1/3).

68945723674934237482 = ?

5782934283492912347898237400000 = ?

34828517376 = (5 characters, Thanks to Ben J in the comments)

432^4

| improve this answer | |
$\endgroup$
  • $\begingroup$ Very nice Jaap! You have matched my best results and improved some of them. $\endgroup$ – Dmitry Kamenetsky Jun 3 at 6:18
  • 1
    $\begingroup$ For the last number, it's possible to golf another 2 characters by rearranging to remove an operator. $\endgroup$ – Ben J Jun 4 at 15:11
  • $\begingroup$ Great observation Ben! $\endgroup$ – Dmitry Kamenetsky Jun 5 at 0:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.