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 code-bowling, so the longest code in characters, not bytes, wins.
-
\$\begingroup\$ "Your base program isn't required to do anything." Is it fine to be invalid? \$\endgroup\$l4m2– l4m22023年10月05日 20:10:23 +00:00Commented Oct 5, 2023 at 20:10
-
\$\begingroup\$ @l4m2 Yes, that's what I was going for, will edit to clarify. \$\endgroup\$noodle person– noodle person2023年10月05日 20:51:30 +00:00Commented Oct 5, 2023 at 20:51
-
\$\begingroup\$ Are negative numbers valid? \$\endgroup\$Command Master– Command Master2023年10月06日 14:41:30 +00:00Commented Oct 6, 2023 at 14:41
-
\$\begingroup\$ Are floats vaild? \$\endgroup\$CursorCoercer– CursorCoercer2023年10月06日 15:42:49 +00:00Commented Oct 6, 2023 at 15:42
-
\$\begingroup\$ @CursorCoercer Yes to both \$\endgroup\$noodle person– noodle person2023年10月06日 16:52:31 +00:00Commented Oct 6, 2023 at 16:52
5 Answers 5
05AB1E, \$\infty\$ characters
20369141745912154102595617074602372501021979838148129261367042484187839780820875821640725982497528535478174327409769295405241482382746825238016107679706574234359475857846801942689179521875304719272368749439413187673971523039421241681202798017924924741462918745857212658216736782561383910642567545351659395459213287812390525XY20369141745912154102595617074602372501021979838148129261367042484187839780820875821640725982497528535478174327409769295405241482382746825238016107679706574234359475857846801942689179521875304719272368749439413187673971523039421241681202798017924924741462918745857212658216736782561383910642567545351659395459213287812390525M1BD.VÁ.V
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>M1BD.VÁ.V, when <number> doesn't have any equal consecutive digits.
If one of 1B 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, then10N+9is executed and returns itself. - If the
.was removed, thenVpops the10N+9and10N+20is returned. - If the
Vwas removed,Árotates the top number, so the output isrot(10N+9).
This is what the number base256 decodes to:
)D g4Qi D21 S èOsθ.ï><4 * -(Y2Ê+,q} ¤.ïi θ>,q}D30Sè` ›iD 30Sè€Sø€ËO sà 4*-,qB} D30Sè `‹iD30 Sè€S ø€ËOsà- ,q }àDsÌ10*s 9aJ0i 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.
-
\$\begingroup\$ Dang, clever, I really didn’t expect anyone to find an infinite solution \$\endgroup\$noodle person– noodle person2023年10月06日 18:46:20 +00:00Commented Oct 6, 2023 at 18:46
Wolfram Alpha, 12 characters
Slight modification of the trivial solution in the community wiki, works for all languages that support superscript numbers as exponentiation
109876543210
09876543210 -> 0
19876543210 -> 1
10876543210 -> 10^876543210
...
10987654321 -> 10^987654321
-
6\$\begingroup\$ Surely you mean
9876543210987654³²¹0for 20 characters...? \$\endgroup\$Dominic van Essen– Dominic van Essen2023年10月05日 20:45:04 +00:00Commented Oct 5, 2023 at 20:45 -
2\$\begingroup\$ @DominicvanEssen That does not work \$\endgroup\$bsoelch– bsoelch2023年10月06日 09:38:50 +00:00Commented Oct 6, 2023 at 9:38
-
\$\begingroup\$ Ah, yes, you're right! \$\endgroup\$Dominic van Essen– Dominic van Essen2023年10月06日 10:22:48 +00:00Commented Oct 6, 2023 at 10:22
R, 13 characters
10^9876543210
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.
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.
Jelly, (削除) 13 (削除ここまで) 14 bytes
10*9876543210H
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.