This is a challenge, the robbers' thread is here

You can change the word code into golf by changing a letter at a time in four steps:


Today, we’ll be doing the same thing with programs.

Your challenge is to:

  • choose a programming language
  • write two programs / functions, one that outputs code and one that outputs golf
  • Such that you can repeatedly change a single character and get a program that outputs an English word until you get to the golf program.
  • Share the code program and the number of times you need to change a character, but not any of the intermediate programs or the golf program, which robbers will try to discover.
  • No two programs can output the same word.

For example, if the program abcde outputs code in a certain language, and the program abcdf outputs potato, then changing that e to an f is a valid step.

And if the program aqcdf outputs golf, then abcde -> abcdf -> aqcdf is a valid chain in which you change a character twice.

You should only share the code program and the number of programs not counting the code program, the rest is for the robbers to guess.

Your solution is cracked when your entire chain of programs is found. It does not have to be your intended solution, only one with the same initial program and same or less length. (If someone finds a longer chain, it’s not a crack.)

If your answer is not cracked after a week, you may mark it as safe and reveal your solution.

Casing can be whatever you want - You can output Code, CODE, coDe, etc. Output may contain a trailing newline.

The dictionary used is /dict/words, which I've put in a gist for convenience.


Your score is the number of programs not counting the code or golf ones, multiplied by the length in bytes of your code program. The safe answer with the lowest score wins.

  • \$\begingroup\$ Do the words have to be distinct? As written it appears that I can have, say, 5 programs that all output code but are 1 character apart, and the final modification outputs golf \$\endgroup\$ Jan 20 at 22:54
  • 1
    \$\begingroup\$ @NoOneIsHere As it says in the challenge body, No two programs can output the same word. \$\endgroup\$
    – emanresu A
    Jan 20 at 22:55
  • 1
    \$\begingroup\$ Oh I missed that, very sorry \$\endgroup\$ Jan 20 at 22:56
  • \$\begingroup\$ Are hashing solutions considered cheesy/discouraged? Sorry if that's dumb, I'm new to cops and robbers challenges \$\endgroup\$ Jan 20 at 23:09
  • \$\begingroup\$ @NoOneIsHere codegolf.meta.stackexchange.com/questions/1061/… \$\endgroup\$
    – emanresu A
    Jan 20 at 23:28

10 Answers 10


JavaScript (ES6), 32 bytes, 4 changes, cracked by Dom Hastings

Should be easier to crack than it was to build. :-p

There are 4 intermediate steps, for a total of 6 programs.


Try it online!


Pari/GP, 28 bytes, 1 step, cracked by M Virts

Let's start from an easy one.


Try it online!

  • \$\begingroup\$ Was your intended solution to remove a character? (if so, you're supposed to change a character, not remove one). \$\endgroup\$
    – emanresu A
    Jan 21 at 3:50
  • \$\begingroup\$ @emanresuA No. Only changing one character to another. \$\endgroup\$
    – alephalpha
    Jan 21 at 3:53
  • \$\begingroup\$ Oh ok. Was asking because of this crack, which got deleted.\ \$\endgroup\$
    – emanresu A
    Jan 21 at 3:55
  • 1
    \$\begingroup\$ codegolf.stackexchange.com/a/241508/100563 \$\endgroup\$
    – M Virts
    Jan 21 at 3:56
  • \$\begingroup\$ Lol beat me to it emanresu A \$\endgroup\$
    – M Virts
    Jan 21 at 3:56

Pari/GP, 26 bytes, 3 changes, cracked by M Virts

Another easy one, using a similar trick.


Try it online!

M Virts found a simple answer with only two changes that I didn't expect. Here is my intended solution:

g=c;f=e;l=d;print(g,o,l,f) /* code */

g=c;f=e l=d;print(g,o,l,f) /* cold */

g c;f=e l=d;print(g,o,l,f) /* gold */

g c f=e l=d;print(g,o,l,f) /* golf */


Vyxal, 4 bytes, 9 changes, crick craked by Aaroneous Miller


Try it Online!

This was kinda fun to create. I'll see what happens!


«ƛ↔ƒ outputs code
«ƛ↔ṙ outputs coal
«ƛ℅ṙ outputs fear
«ƛ℅ṫ outputs feat
«ƛFṫ outputs dent
«ƛF` outputs dell
«ƛ¾` outputs foci
`ƛ¾` outputs program
`ƛ₅` outputs then
`»₅` outputs golf

Try it Online! (last two characters of each line are to print)

Vyxal has two types of string compression. The first, delimited by «, takes the bytes within as a base-255 integer then converts that to base 27 and indexes it into a space plus the alphabet.

We switch through a bunch of these until we get to one where the last character is `, allowing us to change the first character to ` to get into a dictionary compressed regular string.

Vyxal's dictionary compression is fairly simple - it replaces pairs of non-ASCII characters with words from its dictionary, then remaining non-ASCII characters are replaced with words from a shorter dictionary.

This means that a string containing three characters shouldn't be able to return golf. But, I forgot that the short dictionary isn't complete (some slots aren't taken) and those just disappear, which Aaroneous's crack exploited.

Then, we iterate through a few words before getting to the 2-char compression code of golf.

  • \$\begingroup\$ snap crackle pop \$\endgroup\$ Jan 21 at 4:48
  • \$\begingroup\$ @AaroneousMiller I see. Nice job, but I can't really build off what I have so I'll leave it. \$\endgroup\$
    – emanresu A
    Jan 21 at 5:57

Charcoal, 7 bytes * 9 steps = score 63, cracked by Dom Hastings


Try it online! I had to use the full dictionary for this, because there is only one common word that is one source character away from the program for golf and that is gold, after which you would get stuck, however the words nearer the code end are less uncommon.

  • \$\begingroup\$ Did ye not find "Goof" for some reason? \$\endgroup\$
    – Joshua
    Jan 21 at 15:40
  • \$\begingroup\$ @Joshua That's not one source character away from my golf program. \$\endgroup\$
    – Neil
    Jan 21 at 16:05
  • \$\begingroup\$ Cracked! \$\endgroup\$ Jan 23 at 21:41

Perl 5 + -M5.10.0, 43 bytes, 15 changes: score 645: SAFE

17 steps total, 15 excluding code and golf.

Yeah, I don't think this one's going to be a winner! Might be too easy anyway, as I'm pretty sure there's a shorter route than the one I ended up taking but I couldn't quite get it working!

$_=$!=35;/.(.)..(.). (.)(.)/;say$2.$1.$3.$4

Try it online!


I noticed that I could have saved a byte on my solution too using:

$_=$!=35;/.(.)..(.). (.)(.)/;say"$2$1$3$4"; # code

but only after posting and didn't think it was fair to adjust, a whole 15 off my score!

$_=$!=35;/.(.)..(.). (.)(.)/;say$2.$1.$3.$4; # code
$_=$!=35;/.(.)..(.). (.)(.)/;say$3.$1.$3.$4; # dode
$_=$!=35;/.(.)..(.). (.)(.)/;say$3.$1.$3.$1; # dodo
$_=$!=95;/.(.)..(.). (.)(.)/;say$3.$1.$3.$1; # nana
$_=$!=95;/.(.)..(.). (.)(.)/;say$3.$2.$3.$1; # nona
$_=$!=95;/.(.)..(.). (.)(.)/;say$3.$2.$3.$2; # nono
$_=$!=75;/.(.)..(.). (.)(.)/;say$3.$2.$3.$2; # lolo
$_=$!=75;/.(.)..(.). (.)(.)/;say$3.$4.$3.$2; # lalo
$_=$!=75;/.(.)..(.). (.)(.)/;say$3.$4.$3.$3; # lall
$_=$!=75;/.(.)..(.). (.)(.)/;say$5.$4.$3.$3; # all
$_=$!=75;/ (.)..(.). (.)(.)/;say$5.$4.$3.$3; # off
$_=$!=75;/ (.)..(.). (.)(.)/;say$5.$4.$5.$3; # of
$_=$!=75;/ (.)..(.). (.)(.)/;say$5.$4.$5.$5; # o
$_=$!=75;/ (.)..(.). (.)(.)/;say$2.$4.$5.$5; # go
$_=$!=75;/ (.)..(.). (.)(.)/;say$2.$4.$4.$5; # goo
$_=$!=75;/ (.)..(.). (.)(.)/;say$2.$4.$4.$3; # goof
$_=$!=75;/ (.)..(.). (.)(.)/;say$2.$4.$1.$3; # golf

Try it online!

I approached this by first printing out all the 2 digit error messages and looking for words that contained g, o, l and f. Once I had some target regexes I checked if any of them would match code and then refined to pick a regex that would have spaces in (at least some of) the right places. From there I worked manually (because I found it interesting!) to pick a route, although automation would have probably resulted in a better score.

  • \$\begingroup\$ You're piecing together words from error codes... what... \$\endgroup\$
    – emanresu A
    Jan 22 at 22:25
  • 3
    \$\begingroup\$ Yes indeed! Combining Perl's two best features; weird variables that don't feel like they should work and regex! \$\endgroup\$ Jan 22 at 22:32
  • \$\begingroup\$ this one should be safe now \$\endgroup\$
    – Razetime
    Jan 28 at 4:10
  • \$\begingroup\$ @Razetime I thought I was waiting for the 30th! Or at least after 22:18 (GMT) on the 29th, but maybe that's me being overly stringent on the "week" stipulation! I'll hold off 'til Sunday for now, but I'm not sure if anyone's takenmuch of a look anyway! Thanks for the prompt though! \$\endgroup\$ Jan 28 at 10:36
  • \$\begingroup\$ oh sorry i must've misread it \$\endgroup\$
    – Razetime
    Jan 28 at 13:19

!@#$%^&*()_+, 13 bytes * 4 steps = score 52, cracked by Dom Hastings


Try it online!


Perl 5, 35 bytes, 5 steps: score 175: SAFE

7 steps total, 5 excluding code and golf.


Try it online!

When attempting to crack my own previous post, I noticed another way to crack it (using "$2$1$3$4" would have prevented this and also saved a byte...). Changing the variable names (as per some of the other posts) is both efficient and relatively straightforward with the right set of words. The regex match against the error is purely a red herring in this instance.

$_=$!=56;/(.)(o)(.)/;say$1.$2.$3.$'; # code
$_=$!=56;/(.)(o)(.)/;say$1.$2.$3.$f; # cod
$_=$!=56;/(.)(o)(.)/;say$g.$2.$3.$f; # od
$_=$!=56;/(.)(o)(.)/;say g.$2.$3.$f; # god
$_=$!=56;/(.)(o)(.)/;say g.$2.$l.$f; # go
$_=$!=56;/(.)(o)(.)/;say g.$2. l.$f; # gol
$_=$!=56;/(.)(o)(.)/;say g.$2. l. f; # golf

Try it online!

  • 1
    \$\begingroup\$ If this is helpful for anyone cracking, here is a list of Perl error codes 1 to 100. \$\endgroup\$
    – emanresu A
    Jan 30 at 19:13

Python 2, 34 bytes * 2 steps = score 68, cracked by ThisFieldIsRequired

print golf

Try it online!

Easier than you think

  • \$\begingroup\$ crack? \$\endgroup\$
    – ophact
    Jan 25 at 16:49

Python 3, 55 bytes * 2 steps = 110 score, cracked by Aaron

try:exec("print( golf )")

Try it online!


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.