60
\$\begingroup\$

NOTICE - This challenge is now closed. Any new answers will be ignored and the accepted answer will not change

Challenge

Write a valid program which, when just two characters in the program are changed, removed or added, completely changes the output.

The changed output must have a Levenshtein Distance of 15 or more from your original output.

The output must be non empty and finite. Your program therefore must terminate within 1 minute.

Your output must be deterministic, outputting the same thing each time you run the program. It also must not be platform dependent.

Any hash functions are disallowed, as are built in PRNGs. Similarly, seeding an RNG is not allowed.

After a period of three days, an uncracked submission will become safe. In order to claim this safety, you should edit your answer to show the correct answer. (Clarification: Until you reveal the answer, you are not safe and can still be cracked.)

Formatting

Your answer should be in the following format:

# <Language name>, <Program length>

## Code

<code goes here>

## Original Output

<output goes here>

## Changed output

<changed output goes here>

Robbers

The robbers' challenge is to find out which two characters you have changed. If a robber has cracked your solution, they will leave a comment on your answer.

You can find the robbers' thread here.

Winning

The person with the shortest uncracked solution wins.

Leaderboard

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><script>site = 'meta.codegolf';postID = 5686;isAnswer = false;QUESTION_ID = 54464;var safe_list=[];var uncracked_list=[];var n=0;var bycreation=function(x,y){return (x[0][0]<y[0][0])-(x[0][0]>y[0][0]);};var bylength=function(x,y){return (x[0][1]>y[0][1])-(x[0][1]<y[0][1]);};function u(l,o){ jQuery(l[1]).empty(); l[0].sort(o); for(var i=0;i<l[0].length;i++) l[0][i][1].appendTo(l[1]); if(l[0].length==0) jQuery('<tr><td colspan="3" class="message">none yet.</td></tr>').appendTo(l[1]);}function g(p) { jQuery.getJSON('//api.stackexchange.com/2.2/questions/' + QUESTION_ID + '/answers?page=' + p + '&pagesize=100&order=desc&sort=creation&site=codegolf&filter=!.Fjs-H6J36w0DtV5A_ZMzR7bRqt1e', function(s) { s.items.map(function(a) { var he = jQuery('<div/>').html(a.body).children().first(); he.find('strike').text(''); var h = he.text(); if (!/cracked/i.test(h) && (typeof a.comments == 'undefined' || a.comments.filter(function(b) { var c = jQuery('<div/>').html(b.body); return /^cracked/i.test(c.text()) || c.find('a').filter(function() { return /cracked/i.test(jQuery(this).text()) }).length > 0 }).length == 0)) { var m = /^\s*((?:[^,;(\s]|\s+[^-,;(\s])+)\s*(?:[,;(]|\s-).*?([0-9]+)/.exec(h); var e = [[n++, m ? parseInt(m[2]) : null], jQuery('<tr/>').append( jQuery('<td/>').append( jQuery('<a/>').text(m ? m[1] : h).attr('href', a.link)), jQuery('<td class="score"/>').text(m ? m[2] : '?'), jQuery('<td/>').append( jQuery('<a/>').text(a.owner.display_name).attr('href', a.owner.link)) )]; if(/safe/i.test(h)) safe_list.push(e); else uncracked_list.push(e); } }); if (s.length == 100) g(p + 1); else { var s=[[uncracked_list, '#uncracked'], [safe_list, '#safe']]; for(var p=0;p<2;p++) u(s[p],bylength); jQuery('#uncracked_by_length').bind('click',function(){u(s[0],bylength);return false}); jQuery('#uncracked_by_creation').bind('click',function(){u(s[0],bycreation);return false}); } });}g(1);</script><link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"><style>table th,table td { padding: 5px;}th { text-align: left;}.score { text-align: right;}table a { display: block;}.main { float: left; margin-right: 30px;}.main h3,.main div { margin: 5px;}.message { font-style: italic;}</style><div class="main"><h3>Uncracked submissions</h3><table> <tr> <th>Language</th> <th class="score">Length</th> <th>User</th> </tr> <tbody id="uncracked"></tbody></table><div>Sort by: <a href="#" id="uncracked_by_length">length</a> <a href="#" id="uncracked_by_creation">creation</a></div></div><div class="main"><h3>Safe submissions</h3><table> <tr> <th>Language</th> <th class="score">Length</th> <th>User</th> </tr> <tbody id="safe"></tbody></table></div>

\$\endgroup\$
27
  • \$\begingroup\$ @BetaDecay How do you define a hash function? \$\endgroup\$
    – isaacg
    Commented Aug 11, 2015 at 8:47
  • 1
    \$\begingroup\$ @xnor Theoretically, but the number of possibilities increases hugely as the program length increases and so may take a long time \$\endgroup\$
    – Beta Decay
    Commented Aug 11, 2015 at 8:48
  • 1
    \$\begingroup\$ @RedPanda Yes, I would think so \$\endgroup\$
    – Beta Decay
    Commented Aug 11, 2015 at 10:34
  • 5
    \$\begingroup\$ @isaacg I decided to change the safe date to three days \$\endgroup\$
    – Beta Decay
    Commented Aug 12, 2015 at 7:37
  • 4
    \$\begingroup\$ Would it be possible to put the leaderboard code on fewer lines so it takes up less visual room? \$\endgroup\$
    – isaacg
    Commented Aug 13, 2015 at 0:49

76 Answers 76

1 2
3
2
\$\begingroup\$

APL, 9 bytes

Code

+/○3-3⍴⍳5

Original output

18.84955592153876

Changed output

¯0.31830988618379086 0.31830988618379075 0

Looks like I just missed the deadline, because I suck at time zones. Have fun solving this, anyway.

\$\endgroup\$
2
\$\begingroup\$

MATLAB, 56 bytes (SAFE)

I think this is a step up from some of the previous MATLAB questions, but that remains to be seen I guess:

Code

p=.4 -.2*i;j=.3*i +.7;i=@(c)j./(.6- .4*c);asin(i(p) *5i)

Original output

ans =

  -0.2236 + 2.8380i

Changed output

ans =

   0.1799 + 6.5793i   0.1798 + 5.4395i

Solution:

p=.4 -.2*i;j=.3*'i '+.7;i=@(c)j./(.6- .4*c);asin(i(p) *5i)

Simply change .3*i +.7 to .3*'i '+.7; This creates a vector with the numbers [105 32], since MATLAB automatically casts the chars to integers if it's part of an equation.

All the spaces were just to throw people off (it made it possible to do changes like [.3*i 0.7];, thus making it possible to create vectors this way too.

\$\endgroup\$
1
\$\begingroup\$

Cracked

Javascript, 233 bytes

Code

one = 1;
two = one + one;
three = two + one;
zero = three - two - one;
numbers = [three, two, one];

for (i = numbers.length - 1; i >= zero; i--) {
    numbers.pop();
}

infinity = 1 / numbers['length'];
alert(infinity);

Original Output

Infinity

Changed output

3.333333333333333
\$\endgroup\$
2
  • \$\begingroup\$ I tested it on Firefox, Internet Explorer and Chrome. Windows 64bit. I guess your solution could be fine (maybe it's just a rounding in the end). \$\endgroup\$
    – Razvan
    Commented Aug 13, 2015 at 13:11
  • \$\begingroup\$ Cracked, Sorry @Sp3000, posted literal one second after your comment \$\endgroup\$
    – SLuck49
    Commented Aug 13, 2015 at 13:13
1
\$\begingroup\$

Cracked

SWI-Prolog, 54 bytes

Code

assert((o(X,Y,Z):-ABC is X**X,print(ABC))). o(99,y,z).

Original Output

true.

369729637649726772657187905628805440595668764281741102430259972423552570455277523421410650010128232727940978889548326540119429996769494359451621570193644014418071060667659301384999779999159200499899
true.

Changed output

true.

true.
\$\endgroup\$
5
  • \$\begingroup\$ Cracked \$\endgroup\$ Commented Aug 13, 2015 at 9:16
  • \$\begingroup\$ @n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ I'm not really sure if adding a whitespace counts as a "change", I asked the OP about that. If that's ok, then I'll accept it (the way I originally thought really requires two "effective" modifications). \$\endgroup\$
    – mgibsonbr
    Commented Aug 13, 2015 at 18:22
  • \$\begingroup\$ Technically, I can also change the number 99. It's also a trivial change anyway. \$\endgroup\$ Commented Aug 13, 2015 at 22:11
  • \$\begingroup\$ @n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ In that case, well done! What I originally thought was replacing o(99,y,z) for op(99,fy,z), so the 2nd call would just succeed without calling o (and without creating a choice point, like your solution). \$\endgroup\$
    – mgibsonbr
    Commented Aug 14, 2015 at 0:52
  • \$\begingroup\$ BTW for everyone's reference, I only realized a bit too late how similar my attempt and Fatalize's are (otherwise, I wouldn't even have posted this). \$\endgroup\$
    – mgibsonbr
    Commented Aug 14, 2015 at 0:55
1
\$\begingroup\$

Cracked, because I didn't check the simple solution

MATLAB, 8 bytes

Code

sin(1+1)

Original Output

0.909297426825682

Changed Output

-0.262374853703929
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Cracked possibly? \$\endgroup\$
    – Sp3000
    Commented Aug 13, 2015 at 12:45
  • \$\begingroup\$ you need format long enabled to see all the numbers \$\endgroup\$
    – Jonas
    Commented Aug 13, 2015 at 12:45
  • \$\begingroup\$ @Sp3000: yes, of course that works as well :) \$\endgroup\$
    – Jonas
    Commented Aug 13, 2015 at 12:48
1
\$\begingroup\$

PHP, 299

(I hope I have understood the challenge correctly. It seems hard to produce code where and 2 single-character changes make such a difference, even if ignoring whitespace etc.)

Code

<?php $i=0x61;$x=0x15;$y=0x36;$k="";$me=<<<PHP
\$q=\$i=\$i-1;\$x++;\$x=\$x^\$i^$x;if(\$i>0){
for(\$z=0;\$z<__LINE__;\$z++){for(\$l=strlen
("\$me")-1;\$l>=0;\$l--)\$q=\$q^(int)(\$x^
ord(\$me[\$l]));}\$k.=\$q;\$me="/**/\$me";
\$me.="#";eval(\$me);}
PHP;
eval($me);echo wordwrap($k,30,"\n",true)."\n";

FYI: Proof it takes < 1 minute on any modern hardware:

$ time php /tmp/wot.php
711752729711068167264259526921
...
real    0m4.580s
user    0m1.548s
sys     0m3.023s

Original Output

969594939291908988878685848382
818079787776757473727170696867
666564636261605958575655545352
515049484746454443424140393837
363534333231302928272625242322
212019181716151413121110987654
321

Changed output

127127127127127255255255255255
255255255383383383383383383383
383383383511511511511511511511
511511511511511511511639639767
767767767767767895895895895895
895895895895102310231023102311
511151115111511151115111511151
115111511151127912791279127912
791279127912791407140714071407
140714071407140714071407153515
351535153515351535153515351535
\$\endgroup\$
3
  • \$\begingroup\$ I can see a huge number of possible permutations that could be tried in the hex values alone. This seems non-deterministic, which is to say, any small change you make, causes a huge pseudorandom output, so the only way to find it would be to brute force those numbers, or find a solution elsewhere in the code somehow. Beyond my abiliity, I think. \$\endgroup\$ Commented Aug 15, 2015 at 6:07
  • \$\begingroup\$ Obviously my "solution" is (and always was) too long to be a winner ... so I'll drop some hints ;-) The use of eval() is recursive - and changes the output if you add whitespace or debug code in it. You could call the eval'd code directly - and just keep a copy of the eval'd variable string separately for it to use... I think I'd advise you start there. \$\endgroup\$
    – wally
    Commented Aug 17, 2015 at 8:22
  • \$\begingroup\$ ...oh and it intentionally uses loops in loops to make it prohibitively "expensive" to brute force. You might be able to optimize one of them out if you're careful. \$\endgroup\$
    – wally
    Commented Aug 17, 2015 at 8:25
1
\$\begingroup\$

Cracked

Python, 227 Bytes

Original Code:

import re;''.join(re.findall('\w(?=\w\w)','t74q joh7 jv f9dfij9j bfjtf0e nnjen3j nnjrb6fgam3gtm5tem3hj s3eim7djsd3ye d5dfhg5un7ljmm8nan3nn6n k m2ftm5bsof5bf r5arm4ken8 adcm3nub0 nfrn6sn3jfeb6n d m6jda5 gdif5vh6 gij7fnb2eb0g '))

Original Output:

't7jof9dfijbfjtfnnjennnjrb6fgam3gtm5tem3s3eim7djsd3d5dfhg5un7ljmm8nan3nnm2ftm5bsof5r5arm4keadcm3nunfrn6sn3jfebm6jdgdif5vgij7fnb2eb'

Changed Output:

'to iterate is human to recurse divine'
\$\endgroup\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – isaacg
    Commented Aug 14, 2015 at 8:54
1
\$\begingroup\$

Cracked.

CJam, 9 bytes

Attempt 3...

Ps"."-i2b

Try the code at this correct link.

Expected output

1011001010010100001100001010001001010110110100100001

Modified output

5010670554118

Another easy one??

\$\endgroup\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Dennis
    Commented Aug 14, 2015 at 20:00
1
\$\begingroup\$

Cracked

Perl, 48 bytes

Code

$_=cos 99;printf"%.14f",0x7275*sin $_/s/[3-8]/0/

Original Output

287.75699066847318

Changed Output

144.01504526079819
\$\endgroup\$
4
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Dennis
    Commented Aug 15, 2015 at 4:37
  • \$\begingroup\$ crap, that wasn't my solution (though it does work) ... I thought I proofed against that. I had to make some last min changes to hit a proper levenshtein distance. Am I allowed to revise? \$\endgroup\$
    – Adam Katz
    Commented Aug 15, 2015 at 4:43
  • \$\begingroup\$ Editing code in a cops-and-robbers post (especially when cracked) is not allowed, but you can always post a new answer. \$\endgroup\$
    – Dennis
    Commented Aug 15, 2015 at 4:44
  • \$\begingroup\$ nm, cat's out of the bag. accepting. \$\endgroup\$
    – Adam Katz
    Commented Aug 15, 2015 at 4:44
1
\$\begingroup\$

OCTAVE, 157 bytes.

format long 
sin(cos(tan(csc(sec(cot(asin(acos(atan(acsc(asec(acot(sinh(cosh(tanh(csch(sech(coth(asinh(acosh(atanh(acsch(asech(acoth(i))))))))))))))))))))))))

Output:8.77828266022653e+276+3.46629794728664e+276i

Modified Output:1.32478170985912-7.32035312239031i

\$\endgroup\$
17
  • 2
    \$\begingroup\$ Well that's just not fair ;) \$\endgroup\$
    – Beta Decay
    Commented Aug 14, 2015 at 17:52
  • \$\begingroup\$ @BetaDecay Of course it is. It abides by all the rules, eh? But brute force should be able to find the solution easily. \$\endgroup\$
    – Teoc
    Commented Aug 14, 2015 at 17:55
  • \$\begingroup\$ @VladimirLenin He made a winky-face. He knows it's fair. You must've missed it. \$\endgroup\$
    – mbomb007
    Commented Aug 14, 2015 at 17:56
  • \$\begingroup\$ I give a simple estimate of a few thousand adjustments worth trying (roughly 3 for each trig function, choose 2). \$\endgroup\$
    – mbomb007
    Commented Aug 14, 2015 at 18:00
  • 1
    \$\begingroup\$ @LuisMendo it seems to be only compatible with octave, let me change the header \$\endgroup\$
    – Teoc
    Commented Aug 15, 2015 at 15:48
1
\$\begingroup\$

Cracked

Python 3, 57 bytes

Code:

import math, decimal
print(decimal.Decimal(math.tan(749)))

Output:

3.615402552802641888973766981507651507854461669921875

Changed Output:

0.6610431688506868130872362598893232643604278564453125
\$\endgroup\$
1
  • \$\begingroup\$ Cracked? \$\endgroup\$
    – Dennis
    Commented Aug 15, 2015 at 14:42
1
\$\begingroup\$

Cracked

APL, 4

Code

9⍟99

Original Output

2.091329169322069

Changed output

0.11111111111111112

Tested here. Note that the last digit is 2. I just wanted to know how hard is an average APL submission.

\$\endgroup\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Dennis
    Commented Aug 16, 2015 at 17:11
0
\$\begingroup\$

Cracked

Pyth, 4 bytes

.!77

Output:

145183092028285869634070784086308284983740379224208358846781574688061991349156420080065207861248000000000000000000

Changed Output:

3628800
\$\endgroup\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – isaacg
    Commented Aug 14, 2015 at 8:34
0
\$\begingroup\$

Cracked

Python 2, 86 Bytes

Original Code

import dis
def torun():
 print "hello world"
try:
 print dis.dis(torun)
except:
 pass

Original Output:

 47           0 LOAD_CONST               1 ('hello world')
              3 PRINT_ITEM          
              4 PRINT_NEWLINE       
              5 LOAD_CONST               0 (None)
              8 RETURN_VALUE        
None

Changed Output:

The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
\$\endgroup\$
3
  • \$\begingroup\$ In Python 3, those print statements will cause syntax errors. \$\endgroup\$
    – isaacg
    Commented Aug 14, 2015 at 19:53
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Dennis
    Commented Aug 14, 2015 at 19:54
  • \$\begingroup\$ Good job. At least I learned how to use dis in the process of making this one. \$\endgroup\$
    – rp.beltran
    Commented Aug 14, 2015 at 20:27
0
\$\begingroup\$

C, 82 bytes

b=64,i,x[64];main(){for(i=b;i--;)x[(i*3)%b]^=x[(i*5)%b]+i,printf("%02u",x[--b]);}

Output 1:

00006362616059585756555453525150494847464544434241403938373635343332313029282726252423222120191817161514131211100908070605040100

Output 2:

000000006312518624630536342047653158563869074179184088893598110261070111311551196123612751313135013861421145514881520155115811610163816651691171617401763178518061826184518631880189619111925193819501961197119801988222001201400

\$\endgroup\$
0
\$\begingroup\$

JS,

Math.pow(2,10)

Original output:

1024

Changed output:

7.61773480458663923e+85

Has a Levenstein distance of 23(!).

\$\endgroup\$
1 2
3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.