Which character to change (Cops)

Cops, your task is to chose a program that prints a string (you can choose). Although, if you change 1 character in your code, it should print another string.

But there's a twist: You should make your code hard to read, so that the robbers can't find your "changeable" character.

The winner cop is the user, with the shortest answer that wasn't cracked for a week.

Cops, please include the output that should be printed if that specific character is changed in your code.

I will declare the winner cop and robber a week after this challenge is posted.

Example submission (very easy to understand)

# [Vyxal](https://github.com/Vyxal/Vyxal), 8 bytes, prints a and b

1[a|b


• @Shaggy It should output the string that the cop must have referenced in their post. Editing it. Jul 15, 2021 at 10:32
• But all answers can be trivially brute forced, using the exact same algorithm... how much time did you spend thinking before posting this? Did you post this to the sandbox? Jul 15, 2021 at 11:28
• @thedefault. in a Turing-complete language, this provably cannot be brute-forced in the general case. Just write a program that does some complicated looping and you'll never brute-force it Jul 15, 2021 at 14:11
• This seems like a very boring CnR, any answer will either be trivially brute forceable or take advantage of some weird unicode + halting problem thing that makes it very tedious and not really easily doable by a human anyway. Jul 15, 2021 at 21:51
• @pxeger Actually, if you use dovetailing you can always find the solution in finite time provided that one exists. Just run all the programs concurrently. The correct solution will eventually halt, and when it does you can stop execution. Jul 17, 2021 at 13:42

JavaScript (Node.js), 155 bytes, Cracked by hyper-neutrino

z=247275939563830539741033018025n
k=''
e='Hello, world'
while(z) k+=String.fromCharCode(Number(z%128n)),z/=128n;
console.log(eval([...k].reverse().join))


Try it online!

The output should be [Function: bound consoleCall].

• cracked Jul 15, 2021 at 21:59

Vyxals, 13 bytes, Cracked by Aaron Miller

khǍ⇩k•kFk¹↔sU


Try it Online!

Intended text: bcfgjkmnpqstvxz.

• cracked Jul 16, 2021 at 0:36

Japt, 10 bytes, cracked by dingledooper

"1,2"k@X+2


Try it online!

The intended output is 3.4. I have no idea how hard this is to crack, since I barely know any Japt, but hopefully it's not too easy.

• I shall be leaving this one for others to attempt :) Jul 17, 2021 at 19:39
• @Shaggy Ah, so it is easy? :P
– user
Jul 17, 2021 at 19:39
• as with my 2nd solution, when you know how ;) I think most people will figure out what needs to be done quite easily, but less so how to do it. (Sidenote: you could actually golf 2 bytes off this, but I shan't say what they are yet for fear of helping anyone solve it) Jul 17, 2021 at 19:42
• Even if it weren't easy, though, I would have left it for others to attempt. Jul 17, 2021 at 19:46
• Cracked Jul 18, 2021 at 2:24

R, 77 bytes, cracked by tsh

PO=0
TA=TO =min(0 * 0 * 0, FALSE, 0 * 0 * 0)
if(TA|TO&TA&TO)PO=18
LETTERS[PO]


Try it online!

As usual, the string to output is "R".

A previous version of this challenge allowed an unintended crack, found by Dominic van Essen:

R, 71 bytes

PO=0
TA=TO =min(0 * 0 * 0, FALSE, 0 * 0 * 0)
if(TA|TO)PO=18
LETTERS[PO]


Try it online!

• Cracked!... Jul 18, 2021 at 17:40
• Sorry... I've been trying to think-up my own challenges, so I've got a head full of 'tricks' ready to test... Jul 18, 2021 at 17:42
• @DominicvanEssen Nice find! That's not the intended crack, so I've edited in a variation which is immune to your crack. (Doing this rather than posting a new challenge, to avoid completely overwhelming this thread with R answers!) Jul 18, 2021 at 21:54
• Is this work?, another intended crack?
– tsh
Jul 19, 2021 at 2:00
• @DominicvanEssen I won't post it, as I might be able to recycle the idea into a vastly different challenge. :-) Let me know if/when you find it! Jul 19, 2021 at 8:49

><>, 536 bytes, Cracked by ovs

\\ /   \  /  9    \
/\     /  /\  /   \\
/ 1/  \       \\\
\\ //  \  \\  /    \\\
\\  /\ / \\\/ \   \\\\
///  \\   \ \//   // \\
/ /\  \\\ \/ \\ \  \\/ /
\\ / \  \\     /\\ // /
//  /     \\\   \\ \ \  \
\\\  /\\/// \ \\// /  \ +
///\ /\/\/ //   /    /
\\/\\/\/\/ / /// / /3 / n\
// \\     /         \ / /
\ \/\/\/ / // // \/ /  /
\\  //\/\/ / / /  / ;
\//\/\\ /\/\ /     /
\  \    \//\ /    \/
/       //  \ ///
/\\/\/ /\///\\ //
\/\/
//\\//\/     \\
\\  \/    /\/ /\\
\ \  \/  \\  /  //
\  \/  \/
\     /\/ \/


Try it online!

A literal maze of mirrors.

My intended solution was:


\\ /   \  /  9    \
/\     /  /\  /   \\
/ 1/  \       \\\
\\ //  \  \\  /    \\\
\\  /\ / \\\/ \   \\\\
///  \\   \ \//   // \\
/ /\  \\\ \/ \\ \  \\/ /
\\ / \  \\     /\\ // /
//  /     \\\   \\ \ \  \
\\\  /\\/// \ \\// /  \ +
///\ /\/\/ //   /    /
\\/\\/\/\/ / /// / /3 / n\
// \\     /         \ / /
\ \/\/\/ / // // \/ /  /
\\  //\/\/ / / /  / ;
\//\/\\ /\/\ /     /
\  \    \//\ /    \/
/       //  \ ///
/\\/\/ /\///\\ //
\/\X
//\\//\/     \\
\\  \/    /\/ /\\
\ \  \/  \\  /  //
\  \/  \/
\     /\/ \/

where the X is a \, and originally was a /.

Execution paths:

I'm not sure if this makes it more understandable or more confusing.

Red is path before the split, yellow is original, orange is correct path.

• Cracked
– ovs
Jul 26, 2021 at 10:05

Julia 1.x, 53 bytes, Cracked by Robin Ryder

show(sum(count.(==('1'),bitstring.(Int16[9973%36]))))


Try it online!

should output 5

• Cracked! Jul 27, 2021 at 11:54

Vyxal, 14 bytes, Cracked by Aaron Miller

‛ø»:K:Ẋf∑$βS2Ẏ  Try it Online! Should output 14. My intended solution was: »ø»:K:Ẋf∑$βS2Ẏ


I'm quite surprised that changing the word worked, my intention was changing it to a number, where the output would be 1412 before slicing.

• Cracked Jul 27, 2021 at 14:45

JavaScript (REPL), 17 bytes

a=!![],a++,a+=![]


Edit : Actually output "2", should output 3 when the good char is modified

(not sure if the console.log was required or not...)

https://jsconsole.com/

• A cop submission to this challenge must include an intended output string the robber should get. Nov 11, 2021 at 0:41
• I've added that ! :)
– Dnb
Nov 11, 2021 at 0:47
• Welcome to Code Golf! This is a pretty tough cop, I've been trying for a little while to crack it. I don't think you need the console.log, although the question's a little unclear. Nov 11, 2021 at 0:58
• Cracked Nov 11, 2021 at 4:10

PHP 7.4.2 - 23 bytes

echo md5("leetspeak!");

Let's go for another try ! :)

This one should output

20bff2eab610b29d183a363727b9bfb5

if correctly modified

https://wtools.io/php-sandbox

Python 3, 44 bytes, cracked by Dlosc

a=6
b=++a++a++++a++a
a=5*5/5**2
print(b*a-b)


Try it online!

Python 3, 44 bytes

a=6
b=++a++a++++a++a
a=5*5/5**2
print(b*1-b)


Try it online!

• Cracked Dec 14, 2021 at 23:33
• @DLosc Nice, also intended. Dec 15, 2021 at 0:09

IPython, 9 bytes

print(1)#


Should print nothing. I rate this easy and hard.

• I don't know what makes IPython different from normal Python, and I'm not sure where I can test this, but would #rint(1)# be a valid crack? Dec 17, 2021 at 14:07
• @AaroneousMiller Uh yeah, I guess. Not intended, though. Dec 17, 2021 at 14:09

APOL, 70 bytes (Easy)

ƒ(56 ¿(%(I(I(∈ )) 4) ¿(F :(33:3():33::()) ¿(F 2  ¿(≐(∈) 2 3))))((X)) )


The cracked output is:

[None, 2, 2, 2, None, 2, 2, 2, None, 2, 2, 2, None, 2, 2, 2, None, 2, 2, 2, None, 2, 2, 2, None, 2, 2, 2, None, 2, 2, 2, None, 2, 2, 2, None, 2, 2, 2, None, 2, 2, 2, None, 2, 2, 2, None, 2, 2, 2, None, 2, 2, 2]

• Could you link to an interpreter we can use to test our cracks? Dec 17, 2021 at 14:05
• @AaroneousMiller Sure, here's one on repl.it replit.com/@GingerIndustries/APOL Dec 17, 2021 at 14:05
• @AaroneousMiller Fixed the help (I hope) Dec 17, 2021 at 14:06
• lol thx, I'll check it out Dec 17, 2021 at 14:06
• cracked Dec 17, 2021 at 14:47

Python 3, 35 bytes

a=-123**6;b=-456**6;print(a*b|b//a)


Try it online!

Might be a bit simple, but I had fun writing it. Output should be 31132910605162826264952179236

Rattle, 8 bytes, cracked by Aaron Miller

<[c]9I^p


Try it Online!

This code outputs the string 10. With one character changed, it should output the string 100.

Explanation of crack:

"<" decrements the pointer, which wraps around to slot 99. "[c]@" concatenates the value at this memory slot (0) to the value on top of the stack. This results in a string of 100 zeroes. "I^" takes the length of this string, giving 100. "p" converts 100 to a string and prints it.

• cracked Jul 16, 2021 at 14:20
• @AaronMiller nice! Was that brute force, or did you use the documentation? Jul 16, 2021 at 15:04
• A bit of both. I looked at the documentation to find some commands I thought might do it, and I also used it to find some commands that had to stay the same, then brute forced from there since I don't quite get the syntax yet. I'd love to learn the language once it's finished, though! Jul 16, 2021 at 15:17

Jelly, 254 bytes (cracked by the default.)

“5gỊƑ!ṆḥḌ³⁻Ɓc?Ạ°þạḅI§Ɠ¦mṪ9ʂ:Nȯx1®Ḟ ƭḣTsÄẉṭ7|ẏẋzⱮɦḲ⁵.ṗbÐɱ8Ñ3"Øȧ¡Ė÷ʠ\¬ṇƥṀœṙRṅẈɓẒ#Ẏỵ⁼Ȧ©MỴƤ⁷ẹ⁴ż;OṃċẊnFḶ¤ȤḟỤẇçİ/ƒjƬhƙA2PẸtX¿ṢḢṡyiṂCd)ÆṣĠʋŒ-ė~YZ⁾ĿṘ²ŀ'ṄLȷU£BSƲɼṛñ½ȥÞ6pḂæ×ẆɠG4ịı\$EƊ¹¥ḃɗ}DK]u*ġṚk⁹ɲḊµṾW+,ȧwß⁺⁸0ọv(<Ɲṁḍl=Q+ð@Çø[Żṫoera&Ọ¢Vḷ¶Ṗ€ƈḋ{⁶ƇĊqḄHḳJ⁽Ȯ%>^ḤṠfƘṬ‘Œ¿


Try It Online!

The output should be:

690699296939718117350621606422816362267173158421165414491974510998788124940831200375657067696758989277663531427881606883007285313136136830578271394860909143130892610035752665368298072483371326623846259135567658705756844088966332891398225673436164647788793408591250973256547482034045337013090045826070073469995435050529779518827764039871801756995315995194485429761879045854501788974715014302780100588547060896111645050429507146677667643527115067082983636640551198432670539417621925424456729027


I imagine this shouldn't be difficult, even just to brute-force with Jelly's SBCS like someone in chat pointed out. I am working on a solution that will be slow to verify so that it is not brute-forceable (even though I don't think any of the other solutions have been brute-forced, I want to try this just for proof of concept), and using permutations or powersets is probably a good approach.

The intended intended solution was to reverse the permutation index. However, for whatever reason, generating a random permutation of 1..250 and indexing into the codepage gave me a duplicate, so I'm not sure if I copy-pasted the wrong string or I'm just really fucking stupid.

Either way, brute-force crack would be the only valid solution since I messed up the format.

• Cracked (by brute force). Jul 16, 2021 at 16:51
• I haven't used the permutation for index built-in because your string has two repetitions: + appears both on positions 191 and 209, and ȧ appears both at 61 and 193 (so it is impossible for the correct input to be a permutation, and thus the 'find a permutation' built-in can't be helpful). In practice, it fails as expected (it returns an input that differs at 2 positions instead of 1) Jul 16, 2021 at 17:10
• @thedefault. wait... what? ... I literally had jelly generate me a random permutation of 1..250... oh well, good crack then Jul 16, 2021 at 17:13

R, 48 bytes, cracked by pxeger

x=z=6
y=0
while(x+y-1>y){x=x-1;z=z+1}
LETTERS[z]


Try it online!

Once again, the string to output is "R".

I think and hope the solution is unique, but I might have missed something. Edit: indeed I had missed something...

• Cracked Jul 16, 2021 at 18:26
• @pxeger Well done! That's not what I had intended, but I was scared I might have missed something like that. Back to the drawing board... Jul 16, 2021 at 18:46

Brainf***, 51 bytes - cracked by dingledooper

++++++++++[>+++++++++++<-]>++.-------.+++++.++++++.


Try it Online!

Right now it outputs pint. Can you make it output ohms?

• Cracked Jul 21, 2021 at 3:59
• Wow, not even ten minutes! Good job! Jul 21, 2021 at 4:02

J, 7 bytes, cracked by Adám

13024e0


Try it online!

Outputs 13024. Cracked solution should output 69420 instead.

Jul 21, 2021 at 7:39

Labyrinth, 7 bytes, cracked by m90

999
!!@


Try it online!

Outputs 99. Change it to 9900.

• – m90
Jul 21, 2021 at 10:44