9
\$\begingroup\$

For each character in your program, the program with that character removed must produce a number smaller than the program with the next character removed. Your base program isn't required to do anything, and may be invalid.

An example submission could be abcd, where bcd outputs 1, acd outputs 4, abd outputs 5, and abc outputs 11.

Your output can be in any format allowed by default (e.g. list of digits, unary string, etc.), but all of your programs must output in the same format.

This is , so the longest code in characters, not bytes, wins.

\$\endgroup\$
5
  • \$\begingroup\$ "Your base program isn't required to do anything." Is it fine to be invalid? \$\endgroup\$
    – l4m2
    Oct 5, 2023 at 20:10
  • \$\begingroup\$ @l4m2 Yes, that's what I was going for, will edit to clarify. \$\endgroup\$
    – noodle man
    Oct 5, 2023 at 20:51
  • \$\begingroup\$ Are negative numbers valid? \$\endgroup\$ Oct 6, 2023 at 14:41
  • \$\begingroup\$ Are floats vaild? \$\endgroup\$ Oct 6, 2023 at 15:42
  • \$\begingroup\$ @CursorCoercer Yes to both \$\endgroup\$
    – noodle man
    Oct 6, 2023 at 16:52

5 Answers 5

11
\$\begingroup\$

05AB1E, \$\infty\$ characters

20369141745912154102595617074602372501021979838148129261367042484187839780820875821640725982497528535478174327409769295405241482382746825238016107679706574234359475857846801942689179521875304719272368749439413187673971523039421241681202798017924924741462918745857212658216736782561383910642567545351659395459213287812390525XY20369141745912154102595617074602372501021979838148129261367042484187839780820875821640725982497528535478174327409769295405241482382746825238016107679706574234359475857846801942689179521875304719272368749439413187673971523039421241681202798017924924741462918745857212658216736782561383910642567545351659395459213287812390525M₁BD.VÁ.V

Try it online!

This technique is capable of generating arbitrarily long solutions, and given here is a 657 characters one.

When removing each character, this outputs

-20369141745912154102595617074602372501021979838148129261367042484187839780820875821640725982497528535478174327409769295405241482382746825238016107679706574234359475857846801942689179521875304719272368749439413187673971523039421241681202798017924924741462918745857212658216736782561383910642567545351659395459213287812390525000
-20369141745912154102595617074602372501021979838148129261367042484187839780820875821640725982497528535478174327409769295405241482382746825238016107679706574234359475857846801942689179521875304719272368749439413187673971523039421241681202798017924924741462918745857212658216736782561383910642567545351659395459213287812390524999
...
-20369141745912154102595617074602372501021979838148129261367042484187839780820875821640725982497528535478174327409769295405241482382746825238016107679706574234359475857846801942689179521875304719272368749439413187673971523039421241681202798017924924741462918745857212658216736782561383910642567545351659395459213287812390524679
-20369141745912154102595617074602372501021979838148129261367042484187839780820875821640725982497528535478174327409769295405241482382746825238016107679706574234359475857846801942689179521875304719272368749439413187673971523039421241681202798017924924741462918745857212658216736782561383910642567545351659395459213287812390524678
-20369141745912154102595617074602372501021979838148129261367042484187839780820875821640725982497528535478174327409769295405241482382746825238016107679706574234359475857846801942689179521875304719272368749439413187673971523039421241681202798017924924741462918745857212658216736782561383910642567545351659395459213287812390527
-20369141745912154102595617074602372501021979838148129261367042484187839780820875821640725982497528535478174327409769295405241482382746825238016107679706574234359475857846801942689179521875304719272368749439413187673971523039421241681202798017924924741462918745857212658216736782561383910642567545351659395459213287812390526
-20369141745912154102595617074602372501021979838148129261367042484187839780820875821640725982497528535478174327409769295405241482382746825238016107679706574234359475857846801942689179521875304719272368749439413187673971523039421241681202798017924924741462918745857212658216736782561383910642567545351659395459213287812390525
...
-20369141745912154102595617074602372501021979838148129261367042484187839780820875821640725982497528535478174327409769295405241482382746825238016107679706574234359475857846801942689179521875304719272368749439413187673971523039421241681202798017924924741462918745857212658216736782561383910642567545351659395459213287812390204
-20369141745912154102595617074602372501021979838148129261367042484187839780820875821640725982497528535478174327409769295405241482382746825238016107679706574234359475857846801942689179521875304719272368749439413187673971523039421241681202798017924924741462918745857212658216736782561383910642567545351659395459213287812390203
-3
01
625
997
998
20369141745912154102595617074602372501021979838148129261367042484187839780820875821640725982497528535478174327409769295405241482382746825238016107679706574234359475857846801942689179521875304719272368749439413187673971523039421241681202798017924924741462918745857212658216736782561383910642567545351659395459213287812390526
203691417459121541025956170746023725010219798381481292613670424841878397808208758216407259824975285354781743274097692954052414823827468252380161076797065742343594758578468019426891795218753047192723687494394131876739715230394212416812027980179249247414629187458572126582167367825613839106425675453516593954592132878123905259
203691417459121541025956170746023725010219798381481292613670424841878397808208758216407259824975285354781743274097692954052414823827468252380161076797065742343594758578468019426891795218753047192723687494394131876739715230394212416812027980179249247414629187458572126582167367825613839106425675453516593954592132878123905270
920369141745912154102595617074602372501021979838148129261367042484187839780820875821640725982497528535478174327409769295405241482382746825238016107679706574234359475857846801942689179521875304719272368749439413187673971523039421241681202798017924924741462918745857212658216736782561383910642567545351659395459213287812390525

Explanation

This code has a pattern of <number>XY<number>M₁BD.VÁ.V, when <number> doesn't have any equal consecutive digits.

If one of ₁B is removed then the code will output 01 or 625 respectively. Otherwise, the number will be base256 decoded and then run as an 05AB1E. This code inspects the stack, to detect which character was removed, if it wasn't one of .VÁ.V, output the correct number, and exit.

If the first . is removed, then V saves the code to the Y variable, which we can also detect and output 998.

If the first V is removed, we get .Á.V, where rotates the stack, so this is detected by inspection of the stack.

Otherwise, we leave 10N+20, 10N+9 on the stack after the first .V:

  • If the Á was removed, then 10N+9 is executed and returns itself.
  • If the . was removed, then V pops the 10N+9 and 10N+20 is returned.
  • If the V was removed, Á rotates the top number, so the output is rot(10N+9).

This is what the number base256 decodes to:

)D g4Qi D21 S èOsθ.ï><₄ * -(Y2Ê+,q} ¤.ïi θ>,q}D30Sè` ›iD 30Sè€Sø€ËO sà ₄*-,qB} D30Sè `‹iD30 Sè€S ø€ËOsà- ,q }àDsÌ10*s 9ªJ0i     a a  }

This code isn't especially interesting, but notice that there are a lot of spaces there which were inserted by trial-and-error to make sure there aren't any equal consecutive digits (because in that case we can't know which was removed).

<number>XY<number>M leaves <number> at top of the stack even after one character removal: If M was removed, then it's obvious, otherwise at least one instance of <number> must be valid, and it will be the bigger one, which M (which pushes the biggest number on the stack) will push.

\$\endgroup\$
1
  • \$\begingroup\$ Dang, clever, I really didn’t expect anyone to find an infinite solution \$\endgroup\$
    – noodle man
    Oct 6, 2023 at 18:46
5
\$\begingroup\$

Wolfram Alpha, 12 characters

Slight modification of the trivial solution in the community wiki, works for all languages that support superscript numbers as exponentiation

10⁹⁸⁷⁶⁵⁴³²¹⁰
0⁹⁸⁷⁶⁵⁴³²¹⁰  -> 0
1⁹⁸⁷⁶⁵⁴³²¹⁰  -> 1
10⁸⁷⁶⁵⁴³²¹⁰  -> 10^876543210
...

10⁹⁸⁷⁶⁵⁴³²¹  -> 10^987654321

Try it online

\$\endgroup\$
3
  • 6
    \$\begingroup\$ Surely you mean 9876543210⁹⁸⁷⁶⁵⁴³²¹⁰ for 20 characters...? \$\endgroup\$ Oct 5, 2023 at 20:45
  • 2
    \$\begingroup\$ @DominicvanEssen That does not work \$\endgroup\$
    – bsoelch
    Oct 6, 2023 at 9:38
  • \$\begingroup\$ Ah, yes, you're right! \$\endgroup\$ Oct 6, 2023 at 10:22
4
\$\begingroup\$

R, 13 characters

10^9876543210

Attempt This Online!

Languages (like R) that use ^ for exponentiation can gain 1 byte using a slight modification of bsoelch's slight modification of noodle man's CW answer.

\$\endgroup\$
4
\$\begingroup\$

Languages with implicit output - 10 characters

9876543210

876543210 < 976543210 < 986543210 < 987543210 < 987643210 < 987653210 < 987654210 < 987654310 < 987654320 < 987654321.

This works in languages such as Vyxal, Thunno 2, 05AB1E, Japt, PHP, the list goes on. You can edit in your favorite language here if you really want but it's not necessary.

Don't upvote this! It took very little effort. Instead, upvote clever answers in languages that don't abuse this trick.

\$\endgroup\$
2
\$\begingroup\$

Jelly, 13 14 bytes

10*9876543210H

Try it online!

Based on @DominicVanEssen’s R solution in turn based on @bsoelch’s Wolfram Alpha solution. However, now adds one extra monad (H) to the end.

Note the TIO link shows all possible ways of removing a byte but is based on a shorter version of the code since the massive exponentiation times out. Given enough compute and memory it would work as intended.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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