26
\$\begingroup\$

Cops' Challenge

Robbers' challenge here.

It has now been four days since the challenge was posted so all new answers should be marked as non-competing in the title. These answers can still be cracked by robbers but will not go towards their total, and cannot win this challenge.

In this challenge, you (the cops) must write a program which prints out a certain string (to STDOUT) when run (and does not error or print to STDERR).
Then, remove a string of consecutive characters from the code so that it still runs (without erroring or printing to STDERR), but does not give the correct output (or gives no output).

Robbers will try to find the correct characters to add back into the code so that it produces the right (case-sensitive) output (except that there may be an extra trailing newline).
The number of characters they find must be less than or equal to the number of characters removed, so if 4 characters were removed and they find a solution adding in only 3 characters, it is still valid.

In your answer, provide:

  1. The language of the code
  2. The code with characters removed (remember, the characters must be consecutive: you can't remove characters from several different places in the code)
  3. How many characters have been removed
  4. The string that the full program outputs (if there is a trailing newline, you may leave that out)

Remember that your answer is still cracked even if the solution found by the robbers was not intended. For this reason, make sure it is not possible for the robbers to simply put some code which says

Print out the string;
End the program.

(In order to stop this happening, try to minimise the number of characters removed while making sure the submission is still challenging. This will also improve your score.)

The score of an answer is equal to: $$ \operatorname{len}(\text{program with chars removed}) + 2 \times \operatorname{len}(\text{chars removed}) $$ or $$ \operatorname{len}(\text{program}) + \operatorname{len}(\text{chars removed}) $$ (They both equate to the same thing).

Make sure to edit your answer if it has been cracked, and link the robber's post. If the robber found an unintended solution, then you may keep the intended solution a secret so that people can still try to find it.

Example submission

Python, score of 14

Code: print(5*"a")
Number of characters removed: 1
Target output: 5 a (currently outputs aaaaa)

This would be very easy to crack as the character , would just need to be added before the *, but it would be valid.

Scoring

The following scoring criterion will be used in order (if #1 is a tie, then #2 is used to tiebreak, etc.):

  1. The cop with the lowest-score uncracked answer after 1 week wins!
  2. Out of the tied cops, the one whose lowest-scored uncracked answer has the most upvotes wins
  3. Out of the tied cops, the one whose lowest-scored most-upvoted uncracked answer was posted first wins

After 4 days, answers posted to this question will be non-competing (but can still be posted), to stop people posting answers just before the week is over and not giving robbers enough time to crack them.

If it has been four days since this was posted (Saturday 2nd April 2022, after whatever time this was posted in your time zone), please mark your answers as "non-competing" in the title.

Robbers can still crack cops' answers for the remaining 3 days and have those count towards their total; however, cracking non-competing cops' answers does not count towards their total.

Good luck!

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Bit of a n00b question here, but this is my first cops-and-robbers, are cops only allowed to submit one answer, or can you submit multiple? \$\endgroup\$
    – des54321
    Mar 29 at 17:09
  • 3
    \$\begingroup\$ You can submit multiple \$\endgroup\$
    – Lecdi
    Mar 29 at 18:07
  • 2
    \$\begingroup\$ What's the purpose of the "non-competing" rule? There's no reason not to leave the challenge completely open forever, which is what we do with most cops-and-robbers challenges. \$\endgroup\$
    – pxeger
    Apr 4 at 15:48
  • \$\begingroup\$ @pxeger To be completely honest, I forgot what the standard rule was when writing this in the Sandbox, and though "oh I'll just change it when I post it for real"... And then forgot to change it. Now it's been a week anyway so I think I'll just leave it how it is. \$\endgroup\$
    – Lecdi
    Apr 6 at 10:18
  • 1
    \$\begingroup\$ If you're going to accept answers, there's one lower-scoring than the current accepted one. \$\endgroup\$
    – emanresu A
    Apr 8 at 3:55

28 Answers 28

16
\$\begingroup\$

Python 3, score 24, cracked by xnor

print((99,15))
  • 5 characters removed
  • Target output: (6, 9)
  • Current output: (99, 15)

There's a lot of ways to get 6 but (hopefully) only one to get 5.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ well I've figured out the 6-byter, now I just gotta figure out what nonsense you do to get it in 5 \$\endgroup\$
    – des54321
    Mar 30 at 2:58
  • 3
    \$\begingroup\$ cracked, nice one \$\endgroup\$
    – xnor
    Mar 30 at 6:17
12
\$\begingroup\$

Java (OpenJDK 8), 547 + 10 = 557 Cracked by Kevin Cruijssen

import static java.util.stream.Collectors.joining;
import java.util.stream.IntStream;

class Program {
    public static void main(String[] args) {
        System.out.println(new Program());
    }

    String getName(int x) {
        return x + " " + Integer.toHexString(x);
    }

    public String toString() {
        return IntStream.of(130, 14, 8613, 8784, 150, 151).mapToObj(x -> {
            String[] s = getName(x).split(" ");
            int n = (x % 13) % 5;
            return s[n % s.length];
        }).collect(joining(" "));
    }
}

Try it online!

I've never done this before and I see my entry is way longer than others. If that's not appropriate let me know and I'll delete it. Of course, Java is infamously verbose. I could also give a hint about what part of my program the characters were deleted from.

  • 10 characters removed
  • Target output: BREAK OUT FROM THE GUARDED AREA
  • Current output: 130 e 8613 8784 150 97

So, can the robbers break out from the guarded area?

\$\endgroup\$
3
  • 4
    \$\begingroup\$ Not bad!! You could probably have made your score a bit lower by golfing out a lot of whitespace and shortening function names & etc, although it definitely wouldnt compete with some of the other answers here cause java \$\endgroup\$
    – des54321
    Mar 30 at 1:36
  • \$\begingroup\$ cracked Nice answer! You threw me on a loop with the defined getName method, until I realized there is no way it could be modified in just 10 bytes while giving an uppercase output like that. \$\endgroup\$ Mar 30 at 7:43
  • \$\begingroup\$ @KevinCruijssen Well done! I knew the getName method, which becomes totally irrelevant once the characters are added back, might throw people off. Very impressive. You have truly broken out from the guarded area. :) \$\endgroup\$ Mar 30 at 15:27
9
\$\begingroup\$

Jelly, score = 19

A contiguous string of seven bytes was removed from twelve, leaving these five:

49“»V

Running this as a full program now outputs 0, the output of the original program was:

Dyesters opposredoundse urosthenicupdrying@uniocular alkie Elgar ontic)0e eyednesses Kangarooed TPN harvestbug_| Enviability gilly ophiolaterDenebWorst horsRockierU Huey: Yelt aBA

Try it online!

I don't think this will be easy by any stretch of the imagination, but there are some clever people here who might just find one (of the ones?!) that work out of the \$4.3 \times 10^{17}\$ possible programs.


Safe, so how did it work?

I guess this was just a little too much to crack, here's the original program:

 49!’Æfj@⁾“»V - Link:
 49           - fourty-nine        ->  49
   !          - factorial              608281864034267560872252163321295376887552831379210240000000000
    ’         - subtract one           608281864034267560872252163321295376887552831379210239999999999
     Æf       - prime decomposition    [823,3739397,197653021455862028208110725148879567449727922627417829]
         ⁾“»  - list of characters ->  ['“', '»']
        @     - with swapped arguments:
       j      -   join                 ['“',823,3739397,197653021455862028208110725148879567449727922627417829,'»']
            V - evaluate “82337...829» as Jelly code
                    (“...» is Jelly's dictionary-based compression)
 

\$\endgroup\$
7
  • \$\begingroup\$ Just to clarify, 7 + 5 ≠ 13 \$\endgroup\$ Mar 29 at 20:23
  • 1
    \$\begingroup\$ Oops, sorry about that! \$\endgroup\$ Mar 29 at 20:32
  • 1
    \$\begingroup\$ Is this double compression? I'm starting to wonder if the compressed string is a red herring... \$\endgroup\$
    – emanresu A
    Mar 30 at 3:09
  • \$\begingroup\$ @emanresuA despite not really knowing Jelly, I plunged into the docs a bit and tried to reverse engineer this, and it does indeed seem to be double-compressed, as the proper output compresses into a 64-digit number, which interestingly is the product of two primes, but I have no idea what kind of code could create that in Jelly \$\endgroup\$
    – des54321
    Mar 30 at 7:08
  • \$\begingroup\$ @des54321 A bit late, but there's a semi-optimal string compressor that might help you. \$\endgroup\$
    – emanresu A
    Mar 30 at 8:43
9
\$\begingroup\$

Perl 5, score 24, safe

print for a..z
  • 5 characters removed
  • Target output: ABABABABABABABABABABABABAB
  • Current output: abcdefghijklmnopqrstuvwxyz

No interpreter flags or trickery involved, this is pure Perl.

Solution


 print<\3>^B for a..z
 

The code works as is, but replace \3 with a literal \3 character to get the claimed score of 5 characters removed.

\$\endgroup\$
1
  • \$\begingroup\$ This seems hard! There are several easy (and cheesy) 6 character solutions, but the best I can do in 5 chars is A@A@A@A@A@A@A@A@A@A@A@A@A@. \$\endgroup\$ Mar 30 at 17:44
7
\$\begingroup\$

R, score 31, cracked by Dominic van Essen

el(6)

Try it online!

  • 13 characters removed
  • Target output: "Infant.Mortality"
  • Current output: 6

Probably too easy for those familiar with R...

\$\endgroup\$
2
  • 1
    \$\begingroup\$ cracked... \$\endgroup\$ Mar 29 at 20:05
  • 1
    \$\begingroup\$ By the way, this one was the inspiration for mine. When I saw how you were able to get some built-in text that comes with the language, I started asking myself what other text might be built-in somewhere... \$\endgroup\$ Mar 30 at 15:37
5
\$\begingroup\$

Vyxal, 2 + (2 * 4) = 10, safe!

kj

Try it Online!

One last one... Output should be ////\\///\\\//\\\////\\///\\\//\\\////\\///\\\//\\\\///\\///\\\//\\\\///\\///\\\//\\\////\\///\\\//\\\////\\///\\\//\\\////\\///\\\//\\\\///\\///\\\//\\\\///\\///\\\//\\\\///\\///\\\//\\\////\\///\\\//\\\////\\///\\\//\\\\///\\///\\\//\\\\///\\///\\\//\\\\

k/3(:j
Try it Online!
Explanation:
k/      # "/\"
   3(   # 3 times...
     :j # Join by itself
Spoilers = pain

\$\endgroup\$
5
\$\begingroup\$

MATL, score 20. Cracked by Sanchises

'Hey My'

Try it online!

  • 6 characters removed.
  • Target output: Hey Hey My My (displayed with line feed at the end).
  • Current output: Hey My (displayed with line feed at the end).
\$\endgroup\$
3
  • 6
    \$\begingroup\$ what really irritates me about this is you can simply add the missing output to the literal for 7 characters \$\endgroup\$
    – des54321
    Mar 30 at 16:47
  • \$\begingroup\$ codegolf.stackexchange.com/a/245856/32352 Cracked? \$\endgroup\$
    – Sanchises
    Apr 1 at 10:10
  • \$\begingroup\$ @Sanchises Yes! And that was my original code \$\endgroup\$
    – Luis Mendo
    Apr 1 at 10:31
5
\$\begingroup\$

PHP, cracked by dingledooper

  • Score : 45
  • Removed 5 consecutive chars
  • Current output is 38416064248
  • Expected output is 612510483624
<?php for($i=7;$i-->2;)print$i<<$i;

Edited : removed whitespaces and score was updated in consequence. Also assuming short_open_tag are disabled.

\$\endgroup\$
3
  • \$\begingroup\$ Unless I'm missing something, this post's score is \$51\$, not \$39\$. \$\endgroup\$
    – Makonede
    Mar 31 at 0:42
  • \$\begingroup\$ Found something related, though the changing of the second $i to a 1 and the three extra 0s in the output mean that this doesn't work just yet. \$\endgroup\$
    – Makonede
    Mar 31 at 1:05
  • 1
    \$\begingroup\$ Cracked, elegant solution! \$\endgroup\$ Apr 3 at 10:37
4
\$\begingroup\$

R, score 10 + 2×8 = 26, cracked by Dominic van Essen

print("R")

Try it online!

  • 8 characters removed
  • Current output: [1] "R"
  • Target output: [1] R

I haven't done this in a while; I hope I didn't miss an obvious solution!

\$\endgroup\$
5
  • \$\begingroup\$ cracked, but probably not the indended solution... \$\endgroup\$ Mar 30 at 13:29
  • \$\begingroup\$ @DominicvanEssen Well done, hadn't thought of that! Never matter… \$\endgroup\$ Mar 30 at 13:31
  • 1
    \$\begingroup\$ I won't post the intended solution yet, as I may be able to salvage the idea for another challenge... \$\endgroup\$ Mar 31 at 8:03
  • \$\begingroup\$ Great. I'm terrible at thinking-up challenges, but I love trying to solve them... \$\endgroup\$ Mar 31 at 8:35
  • \$\begingroup\$ @DominicvanEssen Here you go! \$\endgroup\$ Mar 31 at 16:49
4
\$\begingroup\$

Python, score 36, cracked by dingledooper

"print("")"
print()
""

Attempt This Online!

Add 7 bytes, and output:

print()
\$\endgroup\$
1
3
\$\begingroup\$

JavaScript (Node.js), 13+23*2=59, Cracked

console.log()

Try it online!

  • Removed 23 characters

  • Should output 39iw027a2hnuqi2c1os255jmjsidafs3nx6496n8vl8dak0qc3r15xwheq4vxpb136up7rsmbm8v5slowjwf7mvj0s751b03gxif5

\$\endgroup\$
1
3
\$\begingroup\$

C (C99, clang), 34 bytes removed + 666 bytes total = 700 score

Try it online!

#include <stdio.h>
#include <string.h>
#define p1 2
#define p2 3
#define p3 (p1+p2)
#define p4 p3+p1
#define p5 p4+p1+p1
#define p6 (p5+p1)
#define p7 p6+p1+p1
#define p8 p7+p1
#define ONEHUNDREDTHIRTYONE (p6*p1*p3 + 1)
#define A (p1<<p6)
#define P0 625*p3
#define P P0*P0
#define P3 (P0*p3)*(p1<<p3)
#define B P/A + A/P
#define C(X,Y) X+X+Y*Y
#define D(W,V) C(W,V)*C(V,W)
#define E(M,N) M+N+1
#define F(X) E(X,p2*X)
#define G F(D(E(B,A),(A,B)))
int main()
{
long long a = p1*p1*p1*p1;
a<<=(p8);
a<<=(p8);
a<<=(p6);
a*=ONEHUNDREDTHIRTYONE;
int g = G;
a/=g;
for(int i = 1; i < (g/(P3)) && a!=0; i++)
{
printf("%llX",F(a));
a/=p1;
}
}

Currently outputs 270F665E11387B32F19C3D99794E1ECCBD270F665D1387B32D9C3D9954E1ECC9270F6651387B319C3D994E1ECD270F651387B19C3D94E1ED270F5138799C3D4E1D270D13859C14E12711399D4D251195

Should output 8300000001418000000120C0000001106000000183000000141800000120C000001106000001830000014180000120C00001106000018300001418000120C0001106000183000141800120C001106001830014180120C01106018301418120C1106183141920D105

A lot of preprocessor trickery was used to set up the challenge which sadly makes it a little less competetive lengthwise.

Hint:

In the intended solution there is no character from either [0-9] or [+,-] sets

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

Python 3, 55 bytes + 3 removed = 58 score CRACKED

print("".join(chr(i)for i in b'wZSSP\x1fhPMS[\x1e'))

Currently outputs wZSSPhPMS[ (Plus two unprintables SE markup hates, check TIO link)

Should output Hello World!

Cracked by Sylvester Kruin

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

Lexurgy, Cracked by Jonathan Allan

\$7 + 2\times 32=71\$ score

a:
*=>w
  • Characters removed: 32
  • Target: zwq
  • Current: w

Original code:

a:
*=>aaa
b:
a=>z/$ _
a=>q/_ $
a=>w
\$\endgroup\$
0
2
\$\begingroup\$

Python, 125 + 34 removed = 159 Cracked

import sys
S=sys.stdout
sys.stdout=type('',(),{'write':lambda x,y:'','flush':lambda z:1})()

Attempt This Online!

Not competitive compared to current Python answers, but I imagine people will find the answer Pythonic

Target output:

Gur Mra bs Clguba, ol Gvz Crgref

Ornhgvshy vf orggre guna htyl.
Rkcyvpvg vf orggre guna vzcyvpvg.

Current output: None

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Given that all other python answers to this have been cracked so far, there isnt exactly much competition for it not to be competitive against \$\endgroup\$
    – des54321
    Mar 30 at 2:32
  • \$\begingroup\$ Very true. We'll see how this one goes \$\endgroup\$
    – jezza_99
    Mar 30 at 2:33
  • \$\begingroup\$ Cracked \$\endgroup\$ Mar 30 at 2:41
2
\$\begingroup\$

Python 3, 23 chars with 4 chars removed = score 27 CRACKED

print(str()[14:18])

Currently outputs nothing, should output Ctrl

Try it online!

\$\endgroup\$
4
  • \$\begingroup\$ You placed spoiler TIO link \$\endgroup\$
    – l4m2
    Mar 30 at 17:29
  • \$\begingroup\$ oh shoot @l4m2 thanks for pointing that out \$\endgroup\$
    – des54321
    Mar 30 at 17:31
  • \$\begingroup\$ its fixed now @l4m2, just no one look at the edit history for the answer :P \$\endgroup\$
    – des54321
    Mar 30 at 17:32
  • \$\begingroup\$ Cracked (and I didn't look at the edit history) \$\endgroup\$ Mar 30 at 21:31
2
\$\begingroup\$

Vyxal, 3 + (2 * 2) = 7, Cracked by Jonathan Allan.

kay

Try it Online!

Should output acegikmoqsuwy]. Bonus challenge: cegikmoqsuwya.

\$\endgroup\$
3
  • \$\begingroup\$ Got it without the bracket, now for that last character... \$\endgroup\$
    – Romanp
    Mar 30 at 14:23
  • \$\begingroup\$ Cracked. The bonus still outstanding. \$\endgroup\$ Mar 30 at 16:54
  • \$\begingroup\$ Bonus solution added to that post ^ \$\endgroup\$ Mar 30 at 16:56
2
\$\begingroup\$

R, score 14 + 2×8 = 30, cracked by Dominic van Essen

`?`=print
?"R"

Try it online!

  • 8 characters removed
  • Current output: [1] "R"
  • Target output: [1] R

This is my second attempt, after Dominic van Essen found an unintended crack to my first attempt. I hope this one is more robust!

\$\endgroup\$
3
  • \$\begingroup\$ Cracked!. I discovered the n*****e function for the first time while trying to crack your previous one (but didn't use it there...).... \$\endgroup\$ Mar 31 at 18:55
  • \$\begingroup\$ @DominicvanEssen Well done, and still not what I intended! Back to the drawing board... \$\endgroup\$ Mar 31 at 19:39
  • \$\begingroup\$ This will probably be my last attempt along this line: codegolf.stackexchange.com/a/245833/86301 \$\endgroup\$ Mar 31 at 19:48
2
\$\begingroup\$

R, score 24 + 2×8 = 40, cracked by Dominic van Essen

{assign("?",print)}
?"R"

Try it online!

  • 8 characters removed
  • Current output: [1] "R"
  • Target output: [1] R

This is my third and probably last attempt, after Dominic van Essen found an unintended crack to my first attempt and then to my second attempt. I hope this one is more robust!

\$\endgroup\$
3
  • \$\begingroup\$ If this isn't the intended crack, please do re-robustify... \$\endgroup\$ Mar 31 at 20:59
  • \$\begingroup\$ @DominicvanEssen That's the one, well done! \$\endgroup\$ Apr 1 at 5:40
  • \$\begingroup\$ Crack posted. Thanks for the extended challenge...! \$\endgroup\$ Apr 1 at 11:58
2
\$\begingroup\$

PHP all versions 64 bits, cracked by dingledooper

  • Score : 50
  • Removed : 12 consecutive ascii chars
  • Current all PHP versions (64 bits) output : /* Nothing */
  • Expected all PHP versions (64 bits) output : 687755285922905
<?php echo '';

Info : The solution may generate a deprecation notice and has possibly no digit.

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

Rust, \$ 26 + (2 \times 12) = 50\$

fn main(){print!("{}",81)}

Try it online!

  • Characters removed: 12
  • Expected output: 0.057987041728136374
  • Currently outputs: 81

I'm putting the solution here, partly so that I don't forget later ;-), but even though the challenge is over, I encourage you to try to figure it out!

If you really want to know the solution, here it is:

fn main(){print!("{}",8f64.exp()%0.1)}
(added f64.exp()%0. between the 8 and the 1)

The f64 converts the 8 to a float, and .exp() returns e^(self) (the exponential function).

Then, the %0.1 returns the remainder from dividing 8f64.exp() by 0.1. The resulting number is 0.057987041728136374.

Try it online!

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

MATL, 11 + 14 = 25 (safe)

'tacocat'0y

Try it online!

Current output:

tacocat
0
tacocat

Desired output, adding 7 bytes:

taataccocaccoaaat

Intended solution

'tacocat'0y"@Yfh])

Try it online!

Forgot about this challenge for a while. Explanation:

'tacocat'          % Push the string 'tacocat'
          y"    ]  % Loop over copy of this string
            @Yf    % Calculate prime factors of each ASCII code point
         0     h   % Concatenate factors, with initial zero
                 ) % Index (modularly) into the original string. Implicit display.
\$\endgroup\$
1
\$\begingroup\$

Vyxal, 3 + (11 * 2) = 25

`İy

Currently outputs </li>y, should output d xdirf irrwst.mreo3//h.s-ksxdiry.

A necessary spoiler: This works on MacOS and probably only there, on the offline Vyxal interpreter.

\$\endgroup\$
1
\$\begingroup\$

Python 3, 20 bytes + 3 removed = 23, Cracked by des54321

print(str()[1:3]*50)

Try it online!

Currently prints an empty string. Should print 100 lowercase L's like so: llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll

\$\endgroup\$
1
1
\$\begingroup\$

StackCell, 8 + (11 * 2) = 30 [non-competing, safe]

"?":[;:]

Current output: ?
Correct output: StackCell

This should be pretty easy

Solution:

"lleCkcatS [null] "?":[;:]

Explanation:

The first " enters string mode.

The bytes 108, 108, 101, 67, 107, 99, 97, 116, 83, and 0 are pushed, in turn (the string \0Stackcell, in reverse).

The second " exits string mode.

The ? pops the top element (0) from the stack, and skips the next instruction (")

Then :[;:] prints the contents of the stack.
: duplicates the top element of the stack to prevent the [/] from consuming the original, [/] form a loop as long as the stack contains a non-null item, and ; pops and prints the top item of the stack as a character

\$\endgroup\$
0
\$\begingroup\$

Behaviour, score = 16 + 2 = 18, cracked by Makonede

@(type:type)-0

just use a language that nobody knows amiright ;)

  • 2 characters removed
  • current output: func
  • desired output: fun

hint:

type is an embeded function that returns the type of a variable. Using type on type results in "cfunc"

The rest of the technics used are on the docs.

I could have made it smaller but the allure of having the output be fun was too great.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ cracked \$\endgroup\$
    – Makonede
    Apr 1 at 16:02
  • \$\begingroup\$ excuse me, cracked \$\endgroup\$
    – Makonede
    Apr 3 at 13:08
  • \$\begingroup\$ I'm sorry, I was on my work's PC and probably didn't save the edit at the time. \$\endgroup\$ Apr 3 at 18:10
0
\$\begingroup\$

C (gcc), 59 bytes + 17 removed = 76 score, non-competing

n=999;main(){for(;printf("%d",n),n*=.9;);}

Currently outputs 99989980972865558953047742938634731228025222620318216314613111710594847567605448433834302724211816141210987654321

Should output 997002512520100

\$\endgroup\$
0
0
\$\begingroup\$

JavaScript (Node.js), 35+23*2=81 bytes, safe

23 hidden chars

console.log([...Array(1e3).keys()])

Try it online!

Current output:

[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562,563,564,565,566,567,568,569,570,571,572,573,574,575,576,577,578,579,580,581,582,583,584,585,586,587,588,589,590,591,592,593,594,595,596,597,598,599,600,601,602,603,604,605,606,607,608,609,610,611,612,613,614,615,616,617,618,619,620,621,622,623,624,625,626,627,628,629,630,631,632,633,634,635,636,637,638,639,640,641,642,643,644,645,646,647,648,649,650,651,652,653,654,655,656,657,658,659,660,661,662,663,664,665,666,667,668,669,670,671,672,673,674,675,676,677,678,679,680,681,682,683,684,685,686,687,688,689,690,691,692,693,694,695,696,697,698,699,700,701,702,703,704,705,706,707,708,709,710,711,712,713,714,715,716,717,718,719,720,721,722,723,724,725,726,727,728,729,730,731,732,733,734,735,736,737,738,739,740,741,742,743,744,745,746,747,748,749,750,751,752,753,754,755,756,757,758,759,760,761,762,763,764,765,766,767,768,769,770,771,772,773,774,775,776,777,778,779,780,781,782,783,784,785,786,787,788,789,790,791,792,793,794,795,796,797,798,799,800,801,802,803,804,805,806,807,808,809,810,811,812,813,814,815,816,817,818,819,820,821,822,823,824,825,826,827,828,829,830,831,832,833,834,835,836,837,838,839,840,841,842,843,844,845,846,847,848,849,850,851,852,853,854,855,856,857,858,859,860,861,862,863,864,865,866,867,868,869,870,871,872,873,874,875,876,877,878,879,880,881,882,883,884,885,886,887,888,889,890,891,892,893,894,895,896,897,898,899,900,901,902,903,904,905,906,907,908,909,910,911,912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,930,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999]

Expected output:

[597,123,155,320,156,214,277,194,228,314,42,93,490,67,0,10,441,478,95,99,500,819,15,787,217,815,769,870,476,794,883,907,914,882,916,895,56,887,38,929,934,261,502,248,935,910,467,452,117,572,942,318,347,504,933,635,468,4,621,175,943,674,688,495,888,927,539,413,133,491,187,475,238,754,605,903,742,75,132,96,902,564,163,941,718,596,890,267,400,341,892,728,894,932,535,429,497,921,52,901,33,415,573,19,457,571,659,308,219,264,554,904,378,310,944,394,523,937,908,695,295,136,983,335,143,950,29,897,379,755,968,770,667,297,624,849,842,877,131,130,396,276,594,486,313,565,545,292,380,83,446,484,881,1,256,434,579,372,47,867,797,406,663,966,555,337,66,699,612,119,820,339,342,763,327,807,580,338,220,780,712,330,984,111,913,196,86,311,602,885,824,680,986,557,87,366,442,975,305,506,924,801,221,167,766,930,100,345,684,515,186,302,343,437,730,939,837,765,630,714,611,449,844,758,869,456,39,459,779,733,122,538,460,543,43,878,958,511,383,138,21,312,551,465,254,756,225,548,647,291,293,14,537,393,31,711,114,987,544,852,533,542,768,514,762,397,598,41,408,286,859,333,928,25,374,363,931,418,751,20,124,303,309,948,492,990,868,646,607,862,481,62,344,633,436,956,681,458,772,61,377,202,55,296,271,631,477,721,268,298,142,325,208,180,529,677,190,280,781,431,886,283,599,185,113,876,184,110,84,282,899,76,782,218,864,118,97,144,370,583,284,922,788,289,32,435,235,140,813,11,160,736,253,584,851,559,826,995,588,251,274,546,422,321,692,189,989,628,810,561,216,988,399,148,73,562,211,13,115,725,696,510,785,812,920,536,381,51,911,255,776,450,239,915,655,30,480,805,165,432,193,106,44,272,629,675,616,236,591,918,980,362,455,17,592,290,371,620,60,483,553,149,800,203,428,709,369,893,773,353,811,961,151,367,58,570,840,340,37,328,161,258,505,532,257,525,294,331,299,550,376,8,209,301,761,171,834,909,121,134,375,959,790,359,317,461,789,463,720,723,964,80,777,905,153,414,508,563,199,830,642,448,618,275,26,823,509,795,757,923,182,49,940,556,2,786,835,803,614,260,919,706,679,796,731,306,648,816,582,57,619,191,994,898,125,92,552,601,753,750,304,802,445,657,729,472,300,970,658,22,398,698,936,90,494,68,145,585,604,129,213,12,694,569,352,307,24,671,722,77,799,273,334,744,285,856,141,517,660,644,227,953,818,74,355,558,322,735,575,18,855,205,263,783,798,732,985,108,395,262,451,792,332,889,833,632,474,973,78,288,825,420,139,498,28,603,440,454,178,704,952,405,891,315,192,357,252,79,316,710,863,45,884,996,516,865,319,896,577,210,560,419,587,323,512,411,900,998,198,748,387,649,668,389,269,945,482,425,822,767,101,181,201,368,473,278,27,669,625,578,600,521,946,724,259,234,574,697,775,734,444,102,403,6,373,154,287,741,738,224,265,195,715,808,326,229,726,846,906,827,183,917,639,120,809,595,222,164,829,279,925,266,7,957,392,626,350,240,866,926,382,72,103,549,232,610,976,507,962,804,447,739,687,513,427,568,764,5,832,845,636,982,576,270,749,850,112,135,360,617,716,147,493,471,609,547,615,105,912,168,737,204,960,527,65,430,281,94,173,88,197,817,401,947,606,622,705,623,991,365,70,346,747,608,955,385,821,645,713,530,760,349,354,967,979,82,409,107,848,324,954,329,567,981,470,627,23,519,412,89,485,656,814,59,358,828,351,439,336,35,16,871,853,831,793,581,104,589,526,361,693,176,685,963,839,858,969,464,593,771,40,703,791,348,745,664,977,364,743,759,503,949,854,701,64,541,206,752,179,700,50,740,690,683,689,433,774,391,386,860,972,34,666,638,177,691,843,158,230,661,416,384,53,872,613,993,438,453,63,407,673,522,586,978,424,650,479,590,85,443,116,421,54,717,528,404,152,388,69,524,971,540,651,3,965,518,231,951,874,157,237,207,520,71,784,634,499,534,778,999,841,247,137,170,172,466,708,566,98,838,719,880,702,857,91,682,496,727,672,487,423,410,806,469,662,390,402,417,81,489,128,426,462,250,501,215,169,9,36,245,46,243,109,127,233,166,146,223,686,707,992,641,670,126,746,241,997,678,242,847,188,162,249,653,150,836,200,654,212,244,938,879,159,640,637,643,861,873,226,875,531,174,665,48,246,974,676,488,356,652]

Notice that the output is an rearrangement and try sort, then there's not large space to test

\$\endgroup\$
0

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.