Robbers' Challenge
Read the cops' challenge first.
In this cops-and-robbers challenge, you (the robbers) must find the correct string of characters, which, when added into the cop's code, will make it produce the correct (case-sensitive) output (except that there may also be an extra trailing newline at the end).
The number of characters you add in must be less than or equal to the number of characters removed from the original code, and your answer is still valid even if it was not intended.
The characters can be added anywhere in the code, but they must all be consecutive in the same place (i.e. not random characters dotted around the code).
Make sure to link the cop's post that you have cracked in your answer, and once you have posted your answer here, comment under the cop's post linking your answer if you have enough reputation.
Example
Say a cop posted the following submission:
Python, score of 14
Code:
print(5*"a")
Number of characters removed: 1
Target output:5 a
(currently outputsaaaaa
)
This is the answer a robber would post to crack it:
Cracks ...'s Python answer (link)
Character to add:
,
before the*
Resulting code:print(5,*"a")
Resulting output:5 a
Scoring
The following scoring criterion will be used in order (if #1 is a tie, then #2 is used to tiebreak, etc.):
- The robber who has cracked the most cops' answers (that were uncracked at the time of posting) after 1 week wins!
- Out of the tied robbers, the one whose most-upvoted answer has the most upvotes wins
- Out of the tied robbers, the one whose most-upvoted answer was posted first wins
Good luck!
19 Answers 19
Python 3, cracks Sisyphus' answer
print(divmod(99,15))
Inserts divmod
where the iv
is U+2173 (Small Roman Numeral Four), a one-character multibyte ligature that normalizes to iv
, letting us squeeze the built-in into 5 characters. I learned of this ligature trick for Python 3 in doing this crack.
-
4\$\begingroup\$ holy cow that works??? there really is no limit to the stupid golfing you can do in python \$\endgroup\$des54321– des543212022年03月30日 07:01:20 +00:00Commented Mar 30, 2022 at 7:01
-
8\$\begingroup\$ @des54321
iv
is 3 bytes whileiv
is 2. It will not help you golfing when answers are scored by bytes (which is default on this site) instead of characters. \$\endgroup\$tsh– tsh2022年03月30日 08:21:12 +00:00Commented Mar 30, 2022 at 8:21
JavaScript (Node.js), cracks l4m2's answer
console.log((99n**77n).toString(34))
Cracking script
let s = "39iw027a2hnuqi2c1os255jmjsidafs3nx6496n8vl8dak0qc3r15xwheq4vxpb136up7rsmbm8v5slowjwf7mvj0s751b03gxif5";
// there's no 'y' and no 'z', so this could be an integer in base 36, 35 or 34
[36, 35, 34].forEach(base => {
let n = [...s].reduce((p, c) => p * BigInt(base) + BigInt(parseInt(c, base)), 0n);
console.log(`Base ${base} -> ${n}`);
// look for divisors of reasonable size
for(let d = 2n; d < 1000n; d++) {
let k = 0, N = n;
while(!(N % d)) { N /= d; k++; }
k && console.log(`${d}**${k}\t${N == 1n ? "success!" : "failed"}`);
}
console.log();
});
Java, cracks David Conrad's answer
Character.
is added before the getName(x)
within the toString()
method.
This took longer than expected..
Explanation:
The Character#getName(int)
method returns the Unicode name for the given character codepoint.
The characters names of the given codepoints 130, 14, 8613, 8784, 150, 151
are in order:
BREAK PERMITTED HERE
SHIFT OUT
UPWARDS ARROW FROM BAR
APPROACHES THE LIMIT
START OF GUARDED AREA
END OF GUARDED AREA
Which then gets split by spaces and the correct word is extracted based on the modulo operators used.
R, cracks Robin Ryder's answer
print("R",,F)
The original answer indicated that 8 characters had been removed; this crack uses only 3 characters:
,,F
, so presumably it isn't the intended solution...
Cracks emanresu A's Vyxal "kay" submission
kaøBy
All we need to do is wrap the alphabetic characters we get from ka
in square brackets before we uninterleave with y
, and that's a two-byte built-in, øB
.
The "bonus" output is achieved with a reversal (Ǔ
) instead: kaǓy
Try it.
-
\$\begingroup\$ Nice! Exactly what I had. \$\endgroup\$emanresu A– emanresu A2022年03月31日 03:19:07 +00:00Commented Mar 31, 2022 at 3:19
PHP, cracks Michel's answer
<?php for($i=7;$i-->2;)print$i<<print$i;
The main observation is that the expected output (612510483624
) can be split in such a way that an obvious pattern emerges: 6 12 5 10 4 8 3 6 2 4
. It follows a consistent pattern of $i*2 $i ...
.
The tricky bit is figuring out how to print it, but it turns out to be as simple as inserting a print
before the second $i
. The rightmost print
is evaluated first, printing $i
, and then $i<<1
is printed, since the other print
returns a 1
.
Python, cracks pxeger's answer
"print("")" print(__doc__) ""
TIL you can store a string inside __doc__
by adding it on the first line.
Python 3, Cracks des54321's answer
print(str(quit)[14:18])
OR
print(str(exit)[14:18])
I brute-forced this by running:
import gc
for x in gc.get_objects():
if str(x)[14:18] == "Ctrl":
print(x)
-
\$\begingroup\$ good one! I didnt even realize there were two solutions to this \$\endgroup\$des54321– des543212022年03月30日 22:44:03 +00:00Commented Mar 30, 2022 at 22:44
Python 3, cracks thegreatemu's answer
import random as r
r.seed(258117)
print(r.random())
I just brute-forced six-digit seeds, which took 8 seconds to run on TIO.
-
\$\begingroup\$ I should have added some spaces =P \$\endgroup\$thegreatemu– thegreatemu2022年03月30日 23:45:15 +00:00Commented Mar 30, 2022 at 23:45
-
\$\begingroup\$ While the Cop answer for this has been deleted for violating this loophole, I will be leaving this answer up as it is still a valid answer. \$\endgroup\$Jo King– Jo King2022年05月30日 12:24:56 +00:00Commented May 30, 2022 at 12:24
-
1\$\begingroup\$ Ohhh
Yb
returns a \1ドル\times 2\$cell
! I had3etv1e
which is incredibly close but not quite right. From the way it displays,'Hey My'Yb
really looks like it's a \2ドル\times 1\$cell
so I abandoned trying it. \$\endgroup\$Giuseppe– Giuseppe2022年04月01日 11:11:16 +00:00Commented Apr 1, 2022 at 11:11 -
\$\begingroup\$ I was also looking into using
e
based purely on the fact that Luis posted the cops answer :) \$\endgroup\$Sanchises– Sanchises2022年04月01日 11:16:46 +00:00Commented Apr 1, 2022 at 11:16
Cracks des54321's Python answer
Adding ^63
after chr(i
results in:
print("".join(chr(i^63)for i in b'wZSSP\x1fhPMS[\x1e'))
...which outputs Hello World!
-
\$\begingroup\$ damn that was fast, I knew this was fairly simple but I thought it would take a bit longer, well deserved +1 \$\endgroup\$des54321– des543212022年03月29日 17:12:17 +00:00Commented Mar 29, 2022 at 17:12
-
1\$\begingroup\$ @des54321 Well, I spent a lot of time today and yesterday coming up with a Python Cop challenge, but you beat me to it, so I though I'd put lots of effort into solving yours ;-). What made it easier what the fact that I'd thought of doing something almost identical, so I still had the
^
chr()
for i in
mindset. \$\endgroup\$Sylvester is on codidact.com– Sylvester is on codidact.com2022年03月29日 17:14:46 +00:00Commented Mar 29, 2022 at 17:14 -
1\$\begingroup\$ great minds think alike I guess :P the fact I was only removing 3 characters also definitely limits the range of what could have gone in there. I did toy around with something more like this so that each character was transformed differently, but if I removed the two byte-strings there would be too many ways to crack it, and I couldn't think of anything short that wouldn't make it easily crackable \$\endgroup\$des54321– des543212022年03月29日 17:19:07 +00:00Commented Mar 29, 2022 at 17:19
-
1\$\begingroup\$ @des54321 Yeah, I saw this challenge in the Sandbox, and started writing a potential Cop answer in Python, thinking it would be easy to do. However, I still hadn't settled on something I liked even after two days. It was fun to crack, though! After I discovered that multiplying
i
by something didn't work, I actually brute-forced it by running a loop exactly like this. \$\endgroup\$Sylvester is on codidact.com– Sylvester is on codidact.com2022年03月29日 17:24:12 +00:00Commented Mar 29, 2022 at 17:24 -
1\$\begingroup\$ My fault for making it too easy to bruteforce I guess :P I did consider throwing some more bitwise operators in there, but I confess I never even thought of multiplying
i
. I guess cause anything I tried that sent the encrypted string out of ASCII space wouldn't work, cause bytestrings can only be ascii (Although I suppose I couldve used thebytes()
constructor and specified non-ascii encoding 🤔) \$\endgroup\$des54321– des543212022年03月29日 17:30:09 +00:00Commented Mar 29, 2022 at 17:30
Crack for bigyihsuan's Lexurgy SC answer
a:
*=>w
b:
w=>zwq
Obviously not the intended solution, but seems to work fine.
-
1\$\begingroup\$ And this is why removing lots of characters from your cop answer isn't good :P it opens the gates for someone to do something cheeky like this \$\endgroup\$des54321– des543212022年03月29日 17:26:59 +00:00Commented Mar 29, 2022 at 17:26
-
1\$\begingroup\$ Not the intended solution, but a crack nonetheless, hehe. gj \$\endgroup\$bigyihsuan– bigyihsuan2022年03月29日 19:20:42 +00:00Commented Mar 29, 2022 at 19:20
Python 3, cracks EphraimRuttenberg's answer:
print(str(...)[1:3]*50)
Added code: ...
inside the str()
.
R, cracks Robin Ryder's second answer
`?`=noquote#print
?"R"
The 8 characters to add are noquote#
.
This exchanges the asssignment of ?
to the print
function into an assignment to the noquote
function, and comments-out the now-useless print
.
R, cracks Robin Ryder's third answer
{assign("?",print.noquote)}
?"R"
The 8 characters to add are .noquote
, changing the print
function into the rather-obscure print.noquote
function.
This series of challenges was an uphill battle for poor Robin Ryder; I think neither of us was fully aware of the variety of noquote
-like options and functions that lurk in base-R, and Robin patiently added more-and-more convoluted re-assignments and curly-braces to counteract each new noquote
variant as it popped up in unintended cracks...
Behavior, cracks Lince Assassino's answer
@(type:type)-0-3
Try it online! (you will have to input the program yourself)
Adds -3
to the end. Removing the -0
originally gives a result of cfunc
, so I assumed -0
meant "remove the character at index 0
." Using the same logic, we add -3
to remove the character at index 3
in func
to get fun
.
Python, 124 bytes, cracks jezza_99's answer
import sys S=sys.stdout sys.stdout=type('',(),{'write':lambda x,y:'','flush':lambda z:1})() import this S.write(this.s[:98])
All of the re-added characters are at the end of the program.
PHP, cracks Michel's answer
<?php echo hexdec(M_E),'';
My first thought was, "maybe the number is large enough that printing it as a hex literal is shorter somehow...". When converting it to hex, I immediately notice that the hex digits are the first few digits of \$ e \$ (0x2718281828459
). The rest is trivial.