8
\$\begingroup\$

Cops thread

Robbers

Robbers, your job is to find the slices of the corresponding cop's code.

Scoring

The robber with the most cracks wins.

Example

Take this code: iimmppoorrtt ssyymmppyy;;pprriinntt((ssyymmppyy..iisspprriimmee((iinnppuutt(())))))

The slice here is [::2], so the robber's post could look like this:

Cracked <somebody>'s answer
```iimmppoorrtt  ssyymmppyy;;pprriinntt((ssyymmppyy..iisspprriimmee((iinnppuutt(())))))```
The slice is [::2].
\$\endgroup\$
7
  • \$\begingroup\$ Add the link to Cops thread \$\endgroup\$
    – Fmbalbuena
    Feb 9, 2022 at 19:03
  • \$\begingroup\$ ok............. \$\endgroup\$ Feb 9, 2022 at 19:04
  • \$\begingroup\$ The unsliced program must be valid code, and your example isn't \$\endgroup\$
    – l4m2
    Feb 9, 2022 at 20:44
  • \$\begingroup\$ @l4m2 well, any suggestions? \$\endgroup\$ Feb 9, 2022 at 20:45
  • \$\begingroup\$ @BgilMidol Suggestion: #iimmppoorrtt ssyymmppyy;;pprriinntt((ssyymmppyy..iisspprriimmee((iinnppuutt(()))))) Slice: [1::2] \$\endgroup\$
    – Aiden Chow
    Feb 10, 2022 at 4:56

12 Answers 12

4
\$\begingroup\$

Python 3, cracks Sisyphus's answer

input((input()[(-1)::1-1-1]))

Try it online!

Given by the slice c[-2158:-4855:-93]

I was initially surprised to find that there were no characters besides those used for input()[::-1]. The input() is a dead giveaway though and a brute force search reduced the input to a handful of possibilities. I then just looked at them individually until I found the correct code.

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

Python 3, 181 bytes

OP

if   True:  print =eval ('  exit')# not  open   u 
exit or  ( eval)('14')
# NO
   
open  or 15* id(  int( int(int (int( id(  print( print([111][:123][:55555-11111111111]))))))))#11;

The slice is simply program[::6], giving us:

irp=(input())
print(irp[::-1]);

Try it online!

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

-3::-14

Python 3, 56 bytes

import sys as s
s.stdout.write(s.stdin.readline()[::-1])

Try it online!

I admit that I used tools

\$\endgroup\$
2
  • \$\begingroup\$ Ah was hoping it would trip people up for a little longer. What tools? \$\endgroup\$
    – jezza_99
    Feb 10, 2022 at 4:20
  • \$\begingroup\$ @jezza_99 Python \$\endgroup\$
    – l4m2
    Feb 10, 2022 at 4:27
2
\$\begingroup\$

Vyxal, cracks emanresuA's answer

ż⇩İ

Generated from a slice of [1:15:6]

\$\endgroup\$
1
  • \$\begingroup\$ Yep, intended solution. \$\endgroup\$
    – emanresu A
    Feb 10, 2022 at 5:32
2
\$\begingroup\$

Vyxal, cracks EmanresuA's second answer

ɖ‡$"t¤+f

Given by the slice [11:33:3]

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

Python 3, cracks AnttiP's answer

[53:586:4] results in:

def g(o):exec("".join(map(chr,map(sum,zip(map(ord,"ikbgm!bginm!\"T33&*V\""),99*[o])))))
x=0
class f:
 def __del__(self):g(x)
y,x=f(),7

Try it online!

g increases each codepoint in "ikbgm!bginm!\"T33&*V\"" by its argument and then executes the resulting string as code. For o=7 this executes print(input()[::-1]).

When the program is done running the garbage collector deletes y, calling g(x) in the process.

\$\endgroup\$
1
  • \$\begingroup\$ Wait, that was the solution? I had found it many times, but I glossed over it every time! \$\endgroup\$
    – ophact
    Feb 14, 2022 at 17:02
1
\$\begingroup\$

Vyxal, 3 bytes, cracks Aaroneous Miller's answer

wRh

Obtained from a slice of [13::-5]. Ngl you should have used that one quirk that only you know about because I know quite a few vyxal quirks too.

\$\endgroup\$
2
  • \$\begingroup\$ You only need to get the last char \$\endgroup\$
    – Fmbalbuena
    Feb 9, 2022 at 22:25
  • \$\begingroup\$ @Fmbalbuena But then the code won't reverse the input string... \$\endgroup\$
    – Aiden Chow
    Feb 10, 2022 at 4:27
1
\$\begingroup\$

brainfuck, Actually cracks l4m2

,[>><,]<[.<]

Try it online!

The slice is c[1::3]. And yes, I literally just bruteforce copy-pasted different slices to TIO, until I found a solution.

\$\endgroup\$
2
  • \$\begingroup\$ Do you brute-force manually? \$\endgroup\$
    – l4m2
    Feb 10, 2022 at 9:26
  • \$\begingroup\$ @l4m2 here I thought that since the code is so short, I might as well do it manually, since there were only like 4 slices I had to check, so it was faster than to write a brainfuck interpreter and bruteforce automatically. But for example for Sisyphus's answer I wrote code. \$\endgroup\$
    – AnttiP
    Feb 10, 2022 at 9:37
1
\$\begingroup\$

Python 3, 72 bytes, cracks ths's answer

i=input();a=len(i);exec("for n in(i*8**9) [1:]:i=(i*a) [::~a]");print(i)

Try it online!

Slice used: code[4981:-201:67]

If you want to see the code finish within your lifetime a bit faster, change the 8**9 to 2 or any other positive even number.

\$\endgroup\$
1
  • \$\begingroup\$ input a 5 letters string, the revert could be done in a few minutes on my laptop as I tested yesterday. So This should finish within your lifetime without changing anything. \$\endgroup\$
    – tsh
    Feb 11, 2022 at 0:04
0
\$\begingroup\$

Python 3.8 (pre-release), 45 bytes, Cracks Big Midol's second answer (new revision)

print(str(str(input()[::-1][::-1][::-1][:])))

Try it online!

Slice is code[145::2]

\$\endgroup\$
1
  • \$\begingroup\$ Not intended, and there is a simpler slice. \$\endgroup\$ Feb 14, 2022 at 11:53
0
\$\begingroup\$

Python 3, 43 bytes, cracks Bgil Midol's second answer (original version)

print(str(str(input()[::-1][::-1][::-1]))) 

Try it online!

Slice is s[40:-10:2]

Fastest crack in the west?

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

Python, cracks Bgil Midol's third cop

[1011::3]

Try it online!

The result of this slice is:

exec("print.__call__(input()[::-1])")
\$\endgroup\$
3
  • \$\begingroup\$ Nice work. There is a simpler version, though. \$\endgroup\$ Feb 14, 2022 at 17:31
  • \$\begingroup\$ @BgilMidol It includes a typo, right? \$\endgroup\$
    – ophact
    Feb 14, 2022 at 17:32
  • \$\begingroup\$ I hope not...................... \$\endgroup\$ Feb 14, 2022 at 17:33

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.