This is a cops-and-robbers challenge, the robbers' thread is here
You can change the word code into golf by changing a letter at a time in four steps:
CODE
COLE
COLD
GOLD
GOLF
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
codeand one that outputsgolf - Such that you can repeatedly change a single character and get a program that outputs an English word until you get to the
golfprogram. - Share the
codeprogram and the number of times you need to change a character, but not any of the intermediate programs or thegolfprogram, 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.
Scoring
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.
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.
_=>(0x63044+185886).toString(36)
-
\$\begingroup\$ Cracked! \$\endgroup\$Dom Hastings– Dom Hastings2022年01月21日 19:50:46 +00:00Commented Jan 21, 2022 at 19:50
Pari/GP, 28 bytes, 1 step, cracked by M Virts
Let's start from an easy one.
go="co";lf="de";print(go,lf)
-
\$\begingroup\$ Was your intended solution to remove a character? (if so, you're supposed to change a character, not remove one). \$\endgroup\$emanresu A– emanresu A2022年01月21日 03:50:44 +00:00Commented Jan 21, 2022 at 3:50
-
\$\begingroup\$ @emanresuA No. Only changing one character to another. \$\endgroup\$alephalpha– alephalpha2022年01月21日 03:53:20 +00:00Commented Jan 21, 2022 at 3:53
-
\$\begingroup\$ Oh ok. Was asking because of this crack, which got deleted.\ \$\endgroup\$emanresu A– emanresu A2022年01月21日 03:55:14 +00:00Commented Jan 21, 2022 at 3:55
-
1\$\begingroup\$ codegolf.stackexchange.com/a/241508/100563 \$\endgroup\$M Virts– M Virts2022年01月21日 03:56:03 +00:00Commented Jan 21, 2022 at 3:56
-
\$\begingroup\$ Lol beat me to it emanresu A \$\endgroup\$M Virts– M Virts2022年01月21日 03:56:48 +00:00Commented Jan 21, 2022 at 3:56
Charcoal, 7 bytes * 9 steps = score 63, cracked by Dom Hastings
⍘⍘$zPγβ
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– Joshua2022年01月21日 15:40:09 +00:00Commented Jan 21, 2022 at 15:40
-
\$\begingroup\$ @Joshua That's not one source character away from my
golfprogram. \$\endgroup\$Neil– Neil2022年01月21日 16:05:46 +00:00Commented Jan 21, 2022 at 16:05 -
\$\begingroup\$ Cracked! \$\endgroup\$Dom Hastings– Dom Hastings2022年01月23日 21:41:36 +00:00Commented Jan 23, 2022 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;/.(.)..(.). (.)(.)/;say2ドル.1ドル.3ドル.4ドル
Solution
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;/.(.)..(.). (.)(.)/;say2ドル.1ドル.3ドル.4ドル; # code
$_=$!=35;/.(.)..(.). (.)(.)/;say3ドル.1ドル.3ドル.4ドル; # dode
$_=$!=35;/.(.)..(.). (.)(.)/;say3ドル.1ドル.3ドル.1ドル; # dodo
$_=$!=95;/.(.)..(.). (.)(.)/;say3ドル.1ドル.3ドル.1ドル; # nana
$_=$!=95;/.(.)..(.). (.)(.)/;say3ドル.2ドル.3ドル.1ドル; # nona
$_=$!=95;/.(.)..(.). (.)(.)/;say3ドル.2ドル.3ドル.2ドル; # nono
$_=$!=75;/.(.)..(.). (.)(.)/;say3ドル.2ドル.3ドル.2ドル; # lolo
$_=$!=75;/.(.)..(.). (.)(.)/;say3ドル.4ドル.3ドル.2ドル; # lalo
$_=$!=75;/.(.)..(.). (.)(.)/;say3ドル.4ドル.3ドル.3ドル; # lall
$_=$!=75;/.(.)..(.). (.)(.)/;say5ドル.4ドル.3ドル.3ドル; # all
$_=$!=75;/ (.)..(.). (.)(.)/;say5ドル.4ドル.3ドル.3ドル; # off
$_=$!=75;/ (.)..(.). (.)(.)/;say5ドル.4ドル.5ドル.3ドル; # of
$_=$!=75;/ (.)..(.). (.)(.)/;say5ドル.4ドル.5ドル.5ドル; # o
$_=$!=75;/ (.)..(.). (.)(.)/;say2ドル.4ドル.5ドル.5ドル; # go
$_=$!=75;/ (.)..(.). (.)(.)/;say2ドル.4ドル.4ドル.5ドル; # goo
$_=$!=75;/ (.)..(.). (.)(.)/;say2ドル.4ドル.4ドル.3ドル; # goof
$_=$!=75;/ (.)..(.). (.)(.)/;say2ドル.4ドル.1ドル.3ドル; # golf
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– emanresu A2022年01月22日 22:25:09 +00:00Commented Jan 22, 2022 at 22:25
-
4\$\begingroup\$ Yes indeed! Combining Perl's two best features; weird variables that don't feel like they should work and regex! \$\endgroup\$Dom Hastings– Dom Hastings2022年01月22日 22:32:38 +00:00Commented Jan 22, 2022 at 22:32
-
\$\begingroup\$ this one should be safe now \$\endgroup\$Razetime– Razetime2022年01月28日 04:10:52 +00:00Commented Jan 28, 2022 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\$Dom Hastings– Dom Hastings2022年01月28日 10:36:07 +00:00Commented Jan 28, 2022 at 10:36
-
\$\begingroup\$ oh sorry i must've misread it \$\endgroup\$Razetime– Razetime2022年01月28日 13:19:48 +00:00Commented Jan 28, 2022 at 13:19
Pari/GP, 26 bytes, 3 changes, cracked by M Virts
Another easy one, using a similar trick.
g=c;f=e;l=d;print(g,o,l,f)
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 */
-
1\$\begingroup\$ ?? codegolf.stackexchange.com/a/241510/100563 \$\endgroup\$M Virts– M Virts2022年01月21日 04:07:16 +00:00Commented Jan 21, 2022 at 4:07
Vyxal, 4 bytes, 9 changes, crick craked by Aaroneous Miller
«ƛ↔ƒ
This was kinda fun to create. I'll see what happens!
Programs:
«ƛ↔ƒ outputs code
«ƛ↔ṙ outputs coal
«ƛc/oṙ outputs fear
«ƛc/oṫ outputs feat
«ƛFṫ outputs dent
«ƛF` outputs dell
«ƛ3⁄4` outputs foci
`ƛ3⁄4` outputs program
`ƛ5` outputs then
`»5` 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\$Aaroneous Miller– Aaroneous Miller2022年01月21日 04:48:00 +00:00Commented Jan 21, 2022 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– emanresu A2022年01月21日 05:57:42 +00:00Commented Jan 21, 2022 at 5:57
-
\$\begingroup\$ Cracked! \$\endgroup\$Dom Hastings– Dom Hastings2022年01月23日 07:43:49 +00:00Commented Jan 23, 2022 at 7:43
Perl 5, 35 bytes, 5 steps: score 175: SAFE
7 steps total, 5 excluding code and golf.
$_=$!=56;/(.)(o)(.)/;say1ドル.2ドル.3ドル.$'
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)(.)/;say1ドル.2ドル.3ドル.$'; # code
$_=$!=56;/(.)(o)(.)/;say1ドル.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
-
1\$\begingroup\$ If this is helpful for anyone cracking, here is a list of Perl error codes 1 to 100. \$\endgroup\$emanresu A– emanresu A2022年01月30日 19:13:31 +00:00Commented Jan 30, 2022 at 19:13
Python 2, 34 bytes * 2 steps = score 68, cracked by ThisFieldIsRequired
golf="code"
goof="cold"
print golf
Easier than you think
Python 3, 55 bytes * 2 steps = 110 score, cracked by Aaron
golf="code"
try:exec("print( golf )")
except:print("a")
-
\$\begingroup\$ cracked \$\endgroup\$Aaroneous Miller– Aaroneous Miller2022年01月27日 18:01:20 +00:00Commented Jan 27, 2022 at 18:01
Explore related questions
See similar questions with these tags.
codebut are 1 character apart, and the final modification outputsgolf\$\endgroup\$