# 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.
– math
Jul 15 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 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 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 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 at 13:42

# Python 3, 51 bytes, cracked by xnor

r=(1,)*8**9
r=r,len,
r=r,str,sum
print(len(str(r)))


Try it online!

The code outputs 402653253. The changed code should instead output 134217728.

I hope my 8**9 will make it difficult for any brute-force methods to work. Good luck!

• Cracked, that was very nice!
– xnor
Jul 21 at 6:22

# Python 2, 23 bytes (cracked by dingledooper)

print min(0,0)>min(0,0)


Try it online!

Should print True. Please don't brute force, I think it's a nice puzzle to solve.

Bonus puzzle!

Python 2, 23 bytes

print min(0,0)<min(0,0)


Try it online!

Should print True. Unfortunately this has an unintended solution of print~min(0,0)<min(0,0), let's just pretend that doesn't exist.

• Cracked (no brute force) Jul 16 at 20:38
• @dingledooper You got it!
– xnor
Jul 16 at 20:39
• I found this for your bonus :) Jul 16 at 20:48
• @dingledooper Yes, it's so evil I just had to include it!
– xnor
Jul 16 at 20:51

# R, 54 bytes, cracked by Dominic van Essen

a=b=c=2
for(a in 0:b)pi=pi+exists("c")/4
intToUtf8(pi)


Try it online!

The string to output is "R".

The solution is to replace the first line with a=b=co2: Try it online! The built-in dataset co2 is then assigned to a and b. When calling 0:b, only the first element of co2 is kept (with a warning); it is worth 315.42, which leads after the for loop to pi=82.246. This is rounded down to 82 by intToUtf8.

• Cracked! Jul 15 at 21:10

# Rattle, 5 bytes, Cracked by Shaggy

d\|!p


Try it Online!

This program outputs the string d. With one character changed, it should output the exact string ['d', '']

Cracked version:

d&|!p

Explanation:

In the original code, d\ is the value of a variable and !p is the code. !p is a program which prints the value at the top of the stack after parsing any input and variables. In this code, d\ gets parsed to d (in this case, \ is null).

In the cracked code, the program stays the same but the variable is d&. The & operator in the variable acts as a separator, so the variable gets parsed to a list containing 'd' and '' (the second value is a null string). Then, the program converts this list to a string and outputs it.

• Is that a string that the cracked version ouputs? 'Cause the challenge fors specifically ask for strings. Jul 15 at 18:39
• @Shaggy yes, ['d', ''] is outputted as a string, although it definitely looks like a list (hint, hint) Jul 15 at 18:41
• Cracked Jul 15 at 20:08

# R, 44 bytes, cracked by Dominic van Essen

a=b=2
for(a in 0:b)pi=a+a-pi
el(LETTERS[pi])


Try it online!

The string to output is "R".

This is (deliberately) similar to my previous answer, but the solution uses a different trick.

The solution is to replace 0:b with 0xb in the for loop: Try it online!. The number Oxb is 11 in hexadecimal. The loop is then just a single call for a=11, leading to pi = 11+11-pi = 18.858..., which gets rounded down to 18. The 18th letter is R.

• Cracked!. Thanks, by the way: I'm loving these (although really spending too much time on them...)! Jul 16 at 11:16
• @DominicvanEssen Well done! They are also fun to come up with. I have one more idea, but haven't managed to wrap it up nicely yet. Jul 16 at 11:43

# VyxalvKOJdaBoVWT, 17 bytes (safe)

₀hf⋏⋏½\zd+∑⇧¨U²


Try it Online!

Solution should output FFIZZBUZZIFIZZBUZZZFIZZBUZZZFIZZBUZZBFIZZBUZZUFIZZBUZZZFIZZBUZZZFIZZBUZZ.

Intended Solution:

₀hf⋏⋏½\zd+∑⇧/U²

All of the flags are valid flags, but the only one that actually did anything important was the d flag, which does a deep sum of the top of the stack before printing.

The main obfuscated part of the program, ₀hf⋏⋏½\zd+∑⇧, simply makes the string FIZZBUZZ.

When executed online, ¨U does nothing, and then ² splits the string, which is put back together by the flag.

In the solution, / causes the string to be wrapped. As a result, w would have also worked. U uniquifies the list, which does nothing since there's only one element. Now, ² is acting on a list instead of a string, so it multiplies the string by itself, which creates a list that is summed by the flag and printed.

• If it jelps, the flags that actually are / may be used are doV. And o only has effects when there's another output, which is unlikely, and V only does stuff when there's a variable, which also seems unlikely. Jul 24 at 22:08
• Close... Jul 25 at 9:40

# Vyxal, 7 bytes, Cracked by Shaggy

kaka[|←


Try it Online!

Uses a quite obscure hack. Should print z if changed correctly.

Shaggy found exactly my intended solution - kaka(|←.

The 'obscure hack' I mentioned is Vyxal's 'ghost variable'. Vyxal's variables are referenced by →name and ←name, but you can give one no name.

(...) is Vyxal's loop construct, but you can add a variable name with (name|...) and that variable will contain the current iteration. This also works with no name, so (|...) sets the ghost variable to whichever iteration, then ← gets the current iteration number. Vyxal's structures autocomplete, so (|... without a closing paren is fine.

You're iterating over ka, which is the lowercase alphabet, so at the end the stack looks like a , b, c... z. Finally, Vyxal's implicit output takes care of the rest, returning the z.

• Cracked Jul 15 at 10:33
• Wow really nice idea
– math
Jul 15 at 10:33

# Vyxal, 5 bytes, Cracked by pxeger

lyoal


Try it Online!

Take two.

Should output name 'this_function' is not defined and nothing else.

May not work in future versions of Vyxal as this is a bug that must be destroyed.

My intended solution was lyxal, which rickrolls you but first outputs the intended text, as you can see in this version, which adds a NOP.

I then realised lyoax works as well.

So yeah, interesting puzzle.

• (rot13 to avoid spoilers) Guvf jnfa'g rira fhccbfrq gb or n cebcre punyyratr, vg jnf whfg na rynobengr evpxebyy, jnfa'g vg? Jul 15 at 10:55
• Cracked! Jul 15 at 11:00
• Cracked EDIT: Damnit, @pxeger! Jul 15 at 11:01

# Pip, 6 bytes, Cracked by Daniel H.

-PI-PI


Try it online!

Outputs -6.283185307179586. The cracked version should output 3.141592653589794.

PI is 3.141592653589793
-PI is -3.141592653589793
PZ-PI is -3.14159265358979397985356295141.3- (palindromize)
-PZ-PI is 3.141592653589794 (casts to float, rounds ...939 to ...94)

• Yes, yes pi wow!
– math
Jul 15 at 17:22
• Is this your intended solution?
– math
Jul 15 at 17:35
• @math That's not quite the right output, I'm afraid. ;) Jul 15 at 17:37
• oh what no the intended output is not pi? even not approximated? nice challenge
– math
Jul 15 at 17:39
• cracked! Jul 15 at 17:45

# R, 51 bytes, cracked by Dominic van Essen

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


Try it online!

The string to output is "R". The previous version allowed for a crack I hadn't intended, found by pxeger. I hope this version is immune to that.

The crack is to replace the while condition x+yy-1>yy by x+yy->>yy. This uses global leftwards assignment ->>, replacing the value of yy at each iteration. That way, we go through the loop 12 times in total, leading to the intended value z=18. In real life, no one ever uses global leftwards assignment, nor should they!
This challenge was inspired by a bug I often see in students' code, in which they expect if(x<-1)... to compare x to -1, but instead it assigns 1 to x. The way to avoid this bug is to type if(x < -1)... of course. IMO, this regular bug is the main argument against using <- instead of = for assignment (there are a few other arguments in the other direction).

• Cracked! Jul 17 at 6:30
• @DominicvanEssen Well done! That's what I intended. I'm out of ideas for now! Jul 17 at 6:49
• I like the anecdote about the student code bug. I personally find the <- R operator too esoteric, and prefer the more-common-in-programming-languages = operator, but this is the fist time I've heard a (very good) argument favouring it for a proper reason! Jul 17 at 9:05

# Vyxal, 34 bytes (safe)

u₁7₌I"
∑C$3Ǎ⇧ *C₍⇧⇩+ Ė_"v⇩÷ CĖ›½½∑  Try it Online! Solution should output 29. Solution: u₁7₌I" ∑C$3Ǎ⇧
*C₍⇧⇩+
Ė_"v⇩÷øCĖ›½½∑

Explanation:

Replaces the last newline with ø, which causes the string to be wrapped in », which is the delimiter for compressed numbers. The string is then decompressed by executing it as Vyxal code with the Ė command, then it is incremented, halved twice, and the digits are added together, equaling 29.

• You can reveal this now. Jul 24 at 22:19

# Vyxalo, 13 bytes, cracked by A username

₴ḟ ₴BuzzF


Try it Online!

Solution should print FizzBuzz.

Intended solution:

₴ḟ kBuzzF

I discovered a parsing bug where you could put a string between the two parts of a diagraph, and the diagraph would still work. In this case, the program is being parsed as ₴ḟ BuzzkF. The first two strings, which are Fizz  and Buzz, don't matter at all, and instead, the final diagraph simply pushes FizzBuzz.

• This is probably the most Vyxal answers I have seen in a question... In 1 year Vyxal will be the best CG language.
– math
Jul 15 at 18:04
• Heh, nice one. I'll leave this to someone else to solve because it's too easy based on our discussion but good one :) Jul 15 at 18:08
• Cracked Jul 15 at 20:43

# Vyxal, 20 bytes, cracked by Aaron Miller

Ẇ₁¹kḢ:∧λf⇧\#¯ḣ⌐ƒż1


Try it Online!

Alright. My turn.

You need to make this epic lambda output who is joe joe mama.

If you thought that the lambda actually did anything, then you were wrong. The first string in the program is to act as a distraction, as the answer is that everything after the : is the compressed version of the output string.

• who's joe? biden?
– math
Jul 15 at 11:10
• The original doesn't seem to output anything? Jul 15 at 11:11
• @shaggy that would be due to an interpreter bug. But consider the original to output an empty string Jul 15 at 11:13
• clearingkelimination? Uh... Jul 15 at 11:26
• Cracked Jul 15 at 13:47

# Python 2, 72 bytes, cracked by the default.

print pow(2,2**1337133713371337,195889276175237072760362930940173700767)


Expected output:

188867410716634269084427012487211003700

• Cracked Jul 16 at 3:57

# Japt, 24 bytes

Hoping this one might be slightly more challenging than my first attempt but I somehow doubt it. The original outputs 1, the cracked version should output 11 (both as strings).

@TwXµY *!ZøX ªX+YÑ}gB Ìs


Try it online!

• "slightly more challenging" is quite an understatement :P
– user
Jul 17 at 18:27
• @user, maybe C&R is a way to increase awareness and usage of Japt 'cause this one is actually pretty easy when you know how. Jul 17 at 19:38
• Cracked. This was a really nice brain teaser, I liked it a lot. Working from back to front helped quite a bit here. Jul 18 at 18:57

# R, 45 bytes, cracked by pajonk

a=b=c=2
for(a in 1:b)c=c*pi
el(LETTERS[-c:0])


Try it online!

The string to output is "R".

This is an homage to Robin Ryder's series of challenges, although I think his ones were cleverer...

• Cracked Jul 17 at 17:34
• Well done. Indeed Robin's ones took longer to be cracked... Jul 17 at 19:42

# Japt, 5 bytes, cracked by user

My turn! Coming up with C&R entries in Japt is always tricky because ... of reasons that would help you solve this! :p (and 'cause I suck at it!) Also, the longer a programme is, the more chance there is for an unintended crack or 2 but, the shorter it is, the easier it is to crack. So this will probably be easily cracked.

Original outputs 0 (as a string), cracked version should output s.

¤ùÅÔÌ


Try it online!

• Cracked!
– user
Jul 17 at 13:45
• Not my intended crack but nicely done, nonetheless :) I realised this was a possibility after posting and meant to change the intended output to prevent it but I must've forgotten. I'll give you the "W", of course, but you're welcome to try for the intended crack too. Jul 17 at 19:37
• Interesting, I'll try to find the intended crack too.
– user
Jul 17 at 19:38
• @user, if you don't get it by the time I get back to my computer on Monday, I'll repost it with the alternative expected output. Jul 17 at 19:40
• @user, it was indeed - very nicely (and quickly) done. The alternative output was p but the principle was identical. Jul 17 at 19:45

# R, 59 bytes, cracked by Dominic

a=as.numeric
bb=strrep(11,1)
"if"(a(bb),LETTERS[a(bb)],"R")


Try it online!

The string to output is "R".

Definitely no match for @Robin's challenges here, but when already this thread is full of R submissions, why not another one?

Intended crack: Try it online!

• Cracked! Jul 17 at 19:38
• And cracked again... Jul 17 at 19:44
• @Dominic, well done. However, none was intended (and second one was easily preventable and wasn't present in last development version). There is another one hidden here. Jul 17 at 20:31
• Hm... cracked again, again... is that the hidden one? Jul 17 at 21:19
• Ups, that is so embarrassing, that it has so many unintended cracks :-\ Jul 18 at 4:54

# JavaScript (SpiderMonkey), 28 bytes, cracked by m90

a=9
if(a>0)a=0
a>9&&print(a)


Try it online!

Output 9 is expected.

A very easy trick. Maybe can be cracked soon (as it is quite short).

Line Feed is a character.

• – m90
Jul 19 at 4:06
• @m90 That is the same as intended crack.
– tsh
Jul 19 at 5:27

# Python 3, 226 bytes - cracked by Zachary Cotton

import operator as o
import inspect as i
a,d = 37,lambda n:n if len(str(n))==1else d(sum(map(int,str(n))))
for k, v in{d(sum(map(ord, n))): f for n, f in i.getmembers(o,i.isbuiltin)[::11]}.items():
a = int(v(a,k**2))
print(a)


Try it online!

It currently prints 520, but it should print 5521. I hope you will enjoy this. I think once you find out the parts of the puzzle, you should be able to see what to change.

# APL (Dyalog Unicode), 19 bytes; cracked by Bubbler

{(⍵ ⍵)(⍵ ⍵)(⍵ ⍵)},8


Prints  8 8 8 8 8 8 : Try it online!

Change one character and make it print 1 instead!

• Cracked Jul 21 at 10:14

# APL (Dyalog Extended), 8 bytes; cracked by Bubbler

≢∊⎕A⍨¨⎕A


Prints 676: Try it online!

Change one character and make it print 286 instead!

• Cracked Jul 21 at 10:14

# VyxalO, 28 bytes (safe)

⁺⟇C‛bf½+ṅĖp⇩D∇⇧$⇧∇∇⇧WṄ3ẇḢht₴  Try it Online! Solution: ⁺⟇C‛bf½+ṅĖpøD∇⇧$⇧∇∇⇧WṄ3ẇḢht₴

Explanation:

Changes the lowercasing and triplicating to dictionary compression. The dictionary compressed string is ₴ḟ₴ḣ, which contains the target string. From there, the rest of the program just does a bunch of random junk to it and winds up with ₴ which is the target string. The ₴ at the end of the program is just a red herring. :)

• You can reveal this now. Jul 24 at 22:20

# Pip, 5 bytes, cracked by Daniel H.

****t


Outputs 179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216. (DON'T Try it online! This code requires the current version of Pip. You can run it here.)

The cracked version should output 42.

The intended solution was

**E*t

which is basically the same as Daniel's crack.

In hindsight,

using an operator that's synonymous with **

may not have been the best idea, but the 42 output was too good to pass up.

• cracked! Jul 15 at 19:43
• ^was that your intended solution? Jul 15 at 19:51
• Pretty close, yeah--see update. Jul 15 at 21:29

# Jelly, 11 bytes, cracked by Aaron Miller

“Y$Ḥß»“¿<ȧ»  Try it online! The output should be hyper-neutrino cause I'm lazy “Y$Ḥß““¿<ȧ» is a list of compressed strings [“Y$Ḥß», “», “¿<ȧ»]. • “Y$Ḥß» decompresses to hyper- (and is a suboptimal compression, specifically to confuse hyper and get him overthinking about the compression engine :P)
• “» decompresses the the empty string, which doesn't then affect the output
• “¿<ȧ» decompresses to neutrino

Then, Jelly smash-prints the string ["hyper-", "", "neutrino"] into hyper-neutrino

• cracked Jul 15 at 21:48
• @AaronMiller Very nice, that was my intended solution! Jul 15 at 21:49

# Vyxals, 13 bytes, Cracked by Aaron Miller

khǍ⇩k•kFk¹↔sU


Try it Online!

Intended text: bcfgjkmnpqstvxz.

• cracked Jul 16 at 0:36

# 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 at 14:20
• @AaronMiller nice! Was that brute force, or did you use the documentation? Jul 16 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 at 15:17

# 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 at 19:39
• @Shaggy Ah, so it is easy? :P
– user
Jul 17 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 at 19:42
• Even if it weren't easy, though, I would have left it for others to attempt. Jul 17 at 19:46
• Cracked Jul 18 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 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 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 at 21:54
• Is this work?, another intended crack?
– tsh
Jul 19 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 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 at 10:05