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

3
\$\begingroup\$

Cracked

VBA, 72 bytes

Sub q()
Dim a(2) As Double
a(0)=-5
a(1)=10
msgbox IRR(a,0.253)
End Sub

Original Output

 0.999999999999136

Adjusted Output

1.82842712474619

Need to see some more VBA representation round here.=) Runs in Excel 2007+

\$\endgroup\$
6
  • \$\begingroup\$ The adjusted output looks so familiar. I feel like that's a number I ought to know. \$\endgroup\$ Commented Aug 12, 2015 at 18:16
  • \$\begingroup\$ @AlexVanLiew The adjusted output is probably equal to 2*sqrt(2)-1 according to WolframAlpha \$\endgroup\$
    – mbomb007
    Commented Aug 12, 2015 at 20:19
  • \$\begingroup\$ @mbomb007 Yeah, that's what I was thinking too. I also feel like that number holds some significance, but I don't think it's a trig special angle and I can't think of what might generate it. \$\endgroup\$ Commented Aug 12, 2015 at 20:27
  • 1
    \$\begingroup\$ cracked \$\endgroup\$
    – mbomb007
    Commented Aug 13, 2015 at 15:47
  • 2
    \$\begingroup\$ Good job. Its hard to hide what your doing in vba. So i went with the fact there are a lot of obscure libraries for finance functions that i thought most programmers won't know what they do. Sadly programmers are fast learners. Might have to try again a little more obscure this time. \$\endgroup\$
    – JimmyJazzx
    Commented Aug 13, 2015 at 17:36
3
\$\begingroup\$

Cracked

bc, 22 bytes

4518574615489737231532

Current output

4518574615489737231532

Desired output

195543687803724
\$\endgroup\$
1
  • \$\begingroup\$ cracked \$\endgroup\$
    – mbomb007
    Commented Aug 13, 2015 at 18:57
3
\$\begingroup\$

Cracked by Luis Mendo

MATLAB, 62 bytes

Code

mistake=-1;tragic=rosser;a=hilb(8)*42;
a(:,:)+tragic(8)/mistake

Original Output

   13.0000   -8.0000  -15.0000  -18.5000  -20.6000  -22.0000  -23.0000  -23.7500
   -8.0000  -15.0000  -18.5000  -20.6000  -22.0000  -23.0000  -23.7500  -24.3333
  -15.0000  -18.5000  -20.6000  -22.0000  -23.0000  -23.7500  -24.3333  -24.8000
  -18.5000  -20.6000  -22.0000  -23.0000  -23.7500  -24.3333  -24.8000  -25.1818
  -20.6000  -22.0000  -23.0000  -23.7500  -24.3333  -24.8000  -25.1818  -25.5000
  -22.0000  -23.0000  -23.7500  -24.3333  -24.8000  -25.1818  -25.5000  -25.7692
  -23.0000  -23.7500  -24.3333  -24.8000  -25.1818  -25.5000  -25.7692  -26.0000
  -23.7500  -24.3333  -24.8000  -25.1818  -25.5000  -25.7692  -26.0000  -26.2000

Changed Output

  -22.0000   19.0000   11.0000  -50.5000  -51.6000    1.0000   -1.0000  -51.7500
   12.0000  -41.0000  -43.5000   -3.6000   -6.0000  -45.0000  -44.7500  -11.3333
   -3.0000  -36.5000  -37.6000  -13.0000  -15.0000  -37.7500  -37.3333  -19.8000
  -29.5000  -17.6000  -20.0000  -31.0000  -30.7500  -25.3333  -26.8000  -29.1818
  -23.6000  -27.0000  -29.0000  -23.7500  -23.3333  -33.8000  -35.1818  -21.5000
  -34.0000  -17.0000  -16.7500  -39.3333  -40.8000  -15.1818  -14.5000  -44.7692
  -43.0000   -9.7500   -9.3333  -47.8000  -49.1818   -7.5000   -6.7692  -53.0000
   -2.7500  -53.3333  -54.8000   -1.1818   -0.5000  -58.7692  -60.0000    1.8000
\$\endgroup\$
4
  • \$\begingroup\$ That's just evil. lol. \$\endgroup\$
    – rayryeng
    Commented Aug 13, 2015 at 14:56
  • \$\begingroup\$ @rayryeng: but it has 42 in it! \$\endgroup\$
    – Jonas
    Commented Aug 13, 2015 at 14:58
  • 2
    \$\begingroup\$ ... and that's why it's even more evil lol. We still don't know what the question is! \$\endgroup\$
    – rayryeng
    Commented Aug 13, 2015 at 14:59
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Luis Mendo
    Commented Aug 13, 2015 at 16:04
3
\$\begingroup\$

Cracked by Luiz Mendo

MATLAB, 40 bytes

Code

format long
arg = [.1 .2 .3];
sin(arg'*exp(9))

Original Output

  -0.220680258232564
  -0.430479305680324
  -0.619052457794081

Changed Output

  -0.803636351328917
  -0.721159584869623
  -0.148487879352133

Hint: there's another solution to this question

\$\endgroup\$
5
  • \$\begingroup\$ But this doesn't fulfill the minimum Levenshtein distance requirement \$\endgroup\$
    – Luis Mendo
    Commented Aug 13, 2015 at 14:24
  • \$\begingroup\$ The Lev. distance for this code is 12. Minimum is 15. \$\endgroup\$
    – rayryeng
    Commented Aug 13, 2015 at 14:29
  • \$\begingroup\$ @rayryeng: apologies, format long added :) \$\endgroup\$
    – Jonas
    Commented Aug 13, 2015 at 14:43
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Luis Mendo
    Commented Aug 13, 2015 at 15:10
  • \$\begingroup\$ @LuisMendo: good job! \$\endgroup\$
    – Jonas
    Commented Aug 13, 2015 at 16:02
3
\$\begingroup\$

Cracked

Javascript, 53 bytes

Code

a=(((b=(a=1)+a)+a)-b-a)*(a=[b])['length'];
alert(a);

Original Output

0

Changed output

5.551115123125783e-18

Tested under: Firefox, Chrome, IE

\$\endgroup\$
3
  • \$\begingroup\$ Interesting. So far, I managed to find 5.551115123125783e-17. \$\endgroup\$
    – Dennis
    Commented Aug 13, 2015 at 13:54
  • \$\begingroup\$ I confirm that it should be e-18. I noticed myself the solution for e-17 \$\endgroup\$
    – Razvan
    Commented Aug 13, 2015 at 13:57
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – jimmy23013
    Commented Aug 14, 2015 at 0:02
3
\$\begingroup\$

Cracked

Lua, 55 bytes

Now with less skimpy underwear! This code might look like my last code that was sadly cracked, but I can assure the solution is completely different

G={load="lfkjgGsHjkU83fy6dtrg"}
print(tostring(G.load))

Current output:

lfkjgGsHjkU83fy6dtrg

The correct output on 64 bit machines:

26

And on 32 bit machines:

18
\$\endgroup\$
4
  • \$\begingroup\$ I can't quite figure this one out. \$\endgroup\$ Commented Aug 13, 2015 at 2:09
  • \$\begingroup\$ Sorry, the output is that number. I'll edit my answer. \$\endgroup\$
    – Nico A
    Commented Aug 13, 2015 at 17:17
  • \$\begingroup\$ Cracked by Xrott? \$\endgroup\$
    – Dennis
    Commented Aug 14, 2015 at 3:33
  • \$\begingroup\$ @Dennis Yeah, I'm pretty sure that's the intended solution \$\endgroup\$ Commented Aug 14, 2015 at 16:52
3
\$\begingroup\$

Cracked.

Stuck, 21 Bytes

I'll start with an easy one, since nobody has seen this before and there's no documents.. Anyways, Stuck is a stack-based language, very similar in usage to CJam. All you need to know is:

NR -> creates a range [1,N] on the stack. 
[N]z -> zips together the top 2 lists, unless an optional N is specified, then the top N lists.
] -> Flattens the top list by one "dimension".

For the record, while I have made commits since this challenge happened, all of this functionality has been present long before.

Code:

1R2R3R4R5R6R7R8R9R9z]

Original Output:

(1, 1, 1, 1, 1, 1, 1, 1, 1)

Changed Output:

(1, 1, 1, 1, 1, 1, 1, 1)(2, 2, 2, 2, 2, 2, 2, 2)(3, 3, 3, 3, 3, 3, 3, 3)
\$\endgroup\$
6
  • \$\begingroup\$ I made a minor edit that I think helps clarify the commands, let me know if it looks good. \$\endgroup\$ Commented Aug 13, 2015 at 17:08
  • \$\begingroup\$ @AlexVanLiew Yeah, that should help clarify :) Thanks! \$\endgroup\$
    – Kade
    Commented Aug 13, 2015 at 17:25
  • \$\begingroup\$ No problem. One other thing: does the R command create an inclusive range or an exclusive range? ie, does 1R push an empty list, or does it push [1]? (same thing for 2R, does it push [1] or [1, 2]?) \$\endgroup\$ Commented Aug 13, 2015 at 18:08
  • \$\begingroup\$ @AlexVanLiew Just clarified that in the post. It's inclusive. \$\endgroup\$
    – Kade
    Commented Aug 13, 2015 at 18:21
  • 1
    \$\begingroup\$ Cracked. \$\endgroup\$ Commented Aug 14, 2015 at 17:22
3
\$\begingroup\$

Cracked

Ruby, 24

Code

p _=?9;p$.+=1until 9#$./

Original Output

"9"

Changed output

"9"
1
2
3
4
5
6
7
8
9
\$\endgroup\$
8
  • 1
    \$\begingroup\$ Do all Ruby programs look like someone took a shotgun loaded with ASCII and shot it at the screen, or just the ones that I see here? \$\endgroup\$ Commented Aug 13, 2015 at 2:51
  • 1
    \$\begingroup\$ Ruby was designed to let you choose whether you imitated Perl (seemingly any random keysmash is valid syntax) or Python (just copy-paste the pseudocode and you're good to go). On these sorts of challenges Perlisms tend to do better. \$\endgroup\$
    – histocrat
    Commented Aug 13, 2015 at 15:03
  • \$\begingroup\$ No kidding. I couldn't even figure out what the original snippet does (random space between p and _? adding 1 to the value of the global that keeps track of line numbers 9 times? or adding 1 to the value of p$., which ought to be nil, which seems like it ought to throw an error?). I'll leave this one for one of the greats. Or at least someone that knows Ruby, ahaha. \$\endgroup\$ Commented Aug 13, 2015 at 17:12
  • \$\begingroup\$ The "9" and trailing / makes me think there is a regex involved here \$\endgroup\$
    – gnibbler
    Commented Aug 14, 2015 at 22:27
  • \$\begingroup\$ This one is totally messing with me... Closest so far is p _=?9;p$.+=1until 9<$.... Arrgghh! :) \$\endgroup\$ Commented Aug 15, 2015 at 12:26
3
\$\begingroup\$

Befunge 98, 30 Bytes(Safe)

Code

153+:*,+:f`#v_
+ ':_;#:-1;#@;,

Original output:

@@@@@@@@@@@@@@@@

Changed output:

@~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#"!

Solution

g53+:*,+:f`#v_
+ ':_;#:-1;#<@;,
\$\endgroup\$
8
  • \$\begingroup\$ Why u so cruel?! \$\endgroup\$
    – mbomb007
    Commented Aug 13, 2015 at 19:49
  • \$\begingroup\$ Is there a trailing space in the changed output? \$\endgroup\$ Commented Aug 14, 2015 at 17:53
  • \$\begingroup\$ @AlexVanLiew no trailing space. The '!' is the last character. \$\endgroup\$
    – MegaTom
    Commented Aug 14, 2015 at 18:46
  • \$\begingroup\$ Alright, I might give this a try when I get home. I've always wanted an excuse to learn this language. Can you link to the interpreter/compiler you used? \$\endgroup\$ Commented Aug 14, 2015 at 18:47
  • \$\begingroup\$ @AlexVanLiew befungius.aurlien.net \$\endgroup\$
    – MegaTom
    Commented Aug 14, 2015 at 18:48
3
\$\begingroup\$

PowerShell v3, 384 (SAFE)

(My second post ever on PPCG, please be gentle. :) I think I'm going to like this community!)

Code:

$s="a*h*t*s*m*i*d*o*n*l*k*e*y*u*g*r*w*LOOD> AIG BAE>!+<R S!>>+<GH MHN JFKL> LOOD AIG BAE>?<+"
$cur="";$l="";[char]$n="A";$st=@{}
foreach($c in [char[]]$s){switch -regex($c){
"[\*\>]" {$st[$n]=$cur.TrimStart(" ");$n=[char]([int]$n-1);if($c-eq">"){$l+=$cur};$cur=""}
"\+" {$l=$cur;$cur=""}
"\<" {$l+$cur;$l="";$cur=""}
default {if($st.Contains($c)){$cur+=$st[$c]}else{$cur+=$c}}}}

Original output:

eggs and ham!
eggs and ham!
do you like eggs and ham?

Modified output:

!

GH MHN JFKL LOOD aIG BaEt

(to be clear, that's a blank line in the middle of the modified output)

Mini-hint:

h/t to Adam Barr for the inspiration

Edit - Safe - Below is corrected code, and below that is explanation

$s = "a*h*t*s*m*i*d*o*n*l*k*e*y*u*g*r*w*LOOD> AIG BAE>!+<R S!>>+<GH MHN JFKL> LOOD AIG BAE>?<+" # The string we're cycling through
$cur = "" # What word(s) we've currently built
$l = "" # The current line we've finished building
[char]$n = "A" # Cast as a character instead of a string, this is the index of our temporary store
$st = @{} # Our temporary store - the first time through, this will populate out with the first part of the string $s
foreach ($c in [char[]]$s) { # Loop through the string $s as an array, one $c character at a time
    switch -regex ($c) {
        "[\*\>]" {
            $st[$n] = $cur.TrimStart(" ") # Ensures that we're not adding a space, and adds what we've currently built into the store
            $n = [char]([int]$n + 1)    #ONE OF THE CHANGES - Changed the +1 to -1, which causes the indexing of the store to be off
            if ($c -eq ">") { $l += $cur } # If our current character is a >, add that to the line as it's finished
            $cur = "" # Reset what we're building
        }
        "\+" {
            $l += $cur #ONE OF THE CHANGES - Changed the += to =, which causes the line to not get printed
            $cur = "" # Reset what we're building
        }
        "\<" {
            $l + $cur # Add on our current word to the line and print it out
            $l = "" # Reset our line
            $cur = "" # Reset what we're building
        }
        default {
            if ($st.Contains($c)) {
                $cur += $st[$c] # If our store contains the character, add what's in the store's index at $c to our current word
            } else {
                $cur += $c # Else, just add the character to our current word
            }
        }
    }
}

Explanation

The best way to explain this is that we're using the string at the start as a sort of cypher. The first half of the string, demarcated by asterisks, is our cypher results. The rest of the string is the output, encoded based off of the "integer" value of the letter (from an alphabetical perspective, not an ASCII perspective). For example, the LOOD> takes the 12th character (an e), the 15th character (a g) twice, and then the 4th character (a s), which forms the word eggs, then the > case, which trims off what we're building so that our words don't run together.

The script cycles through the string character by character, building the cypher store at first (because of all the asterisks, the first 34 times through the switch causes either the first case or the default case to be called), while the rest of the times through cause either an index lookup (because we've already added that letter) or text manipulation (e.g., the second change which just re-sets a variable rather than print it out).

Please let me know if you have further questions!

\$\endgroup\$
1
  • \$\begingroup\$ This is safe now, you can reveal the solution if you wish \$\endgroup\$
    – Beta Decay
    Commented Aug 16, 2015 at 0:13
3
\$\begingroup\$

Fantom, 30 (safe)

Code

[7115432d/9,219.or(64),37][0]

Original Output

790603.5555555556

Changed output

55

Solution

"7115432d/9,219.or(64),37"[0]

By changing the array to a string literal, the index call actually gets the first character of the string. Characters in fantom are actually just ints, so the value of '7' is 55.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Hey, you can still change the . to a , and change the index to 3 ([7115432d/9,219.or(64),37,55,0f][3]). I'll give you grace so you can fix it up again. ;P \$\endgroup\$ Commented Aug 13, 2015 at 17:06
  • 1
    \$\begingroup\$ Hey, thanks, that distraction was too much work for what it was worth \$\endgroup\$
    – Cain
    Commented Aug 13, 2015 at 18:08
  • \$\begingroup\$ You enjoy red herrings, don't you? 119.xor(64) is so close! \$\endgroup\$ Commented Aug 13, 2015 at 18:22
  • \$\begingroup\$ @AlexVanLiew Haha that's the idea, I wanted 55 to come up all over the place \$\endgroup\$
    – Cain
    Commented Aug 13, 2015 at 18:37
3
\$\begingroup\$

Malbolge, 411 bytes

Code

bCBA@?>=<;:9876543210/.-,+*)('&%$#"!~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9y76543210/(L,l$H('&%$#"!~}v{zyxwvutm3qponmlkjihgfedcba`_^]?zZYXWVOTSRQPONMFjJIHGFEDC<`@?!=<;4X87w/S3s10/.-,+*)('&%$#"!~}|{zyxq7Xtmrk1onPlkdihg`&dcbD`_^]\[ZYXQutTSRQPONMLKJCgGFEDCBA@?>=<;:z81Uv43210/.'Kl*#G'&f|{A!~}|{zs9qvo5mrqponmle+*hgfe^c\"`_^]\[ZYXWV8Nr5QPONGkKJ,HGFEDCBA@?>=<;:3W76/432+O/o-,+*)('&%|B/

Original output

Two Makes All The Difference

Modified output

Two 

(note the trailing space)

Solution

bCBA@?>=<;:9876543210/.-,+*)('&%$#"!~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9y76543210/(L,l$H('&%$#"!~}v{zyxwvutm3qponmlkjihgfedcba`_^]?zZYXWcOTSRQPONMFjJIHGFEDC<`@?!=<;4X87w/S3s10/.-,+*)('&%$#"!~}|{zyxq7Xtmrk1onPlkdihg`&dcbD`_^]\[ZYXQutTSRQPONMLKJCgGFEDCBA@?>=<;:z81Uv43210/.'Kl*#G'&f|{A!~}|{zs9qvo5mrqponmle+*hgfe^c\"`_^]\[ZYXWV8sr5QPONGkKJ,HGFEDCBA@?>=<;:3W76/432+O/o-,+*)('&%|B/
\$\endgroup\$
3
\$\begingroup\$

Perl, 49 byes (safe)

Code

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

Original Output

145.9795577401910975

Changed Output

23.3077670014990304

Clue

I tried to do this before but there was another unintended (easier) solution. The robber to my previous challenge may help you solve this one. Try to solve it with three modifications and you'll be half way to the two modification answer.

Solution

$_=cos 99;printf"%.16f",07275*sin $_/y/[3-8]/04/

1. Remove the x to turn hexadecimal 0x7275 (decimal 29301) into octal 07275 (decimal 3773)

2. Change the s/// (replacement) to y/// (transliteration) so that instead of the first digit from 3-8 becoming the string 04, all digits in that range become 4. Additionally, both return the number of changes; the s/// version only makes one change while y/// makes all 8 changes (the way s///g would). If you could change a third character, you could do s/[3-8]/4/g and have the same result as my y/[3-8]/04/. (This was exploited to solve my previous attempt.)

Example of s/// vs y///:

$_="s: 1234567890, ";s/[3-8]/04/;print; $_="y: 1234567890";y/[3-8]/04/;print
s: 12044567890, y: 1244444490
So therefore we're multiplying by a changed number and the function at the end alters the default variable differently and divides by a different number.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Good going! Closest I got was 23.5402686025187862 with $_=cos 99;printf"%.16f",0x1275*sin $_/s/[3-8]/04/ didn't think to change the s///, d'oh! \$\endgroup\$ Commented Aug 19, 2015 at 6:35
2
\$\begingroup\$

Cracked

C++ 91 Bytes

#include <iostream>
int main()
{
    //can you figure it out?
    std::cout << "I like cake and";
}

Output:

I like cake and

Changed output

\$\endgroup\$
7
  • \$\begingroup\$ Your changed output is unclear? Is empty, a single newline or something else? \$\endgroup\$
    – Dennis
    Commented Aug 11, 2015 at 21:55
  • \$\begingroup\$ Cracked. I'm not really sure this is valid, though, as the spec says that output must be non-empty; it's unclear if this refers to both outputs or just the original one. \$\endgroup\$ Commented Aug 11, 2015 at 22:03
  • \$\begingroup\$ This is invalid. None of the outputs can be empty. CC @AlexVanLiew \$\endgroup\$
    – Beta Decay
    Commented Aug 11, 2015 at 22:22
  • \$\begingroup\$ Alex, I can't comment on the other post (not enough rep) but you got me \$\endgroup\$ Commented Aug 11, 2015 at 23:03
  • \$\begingroup\$ @f41lurizer Good try for a first post, but trigraphs and other similar shenanigans are pretty well known around here. Try giving it another go! \$\endgroup\$ Commented Aug 12, 2015 at 18:18
2
\$\begingroup\$

Cracked

PHP 5.4, 92 bytes

<?php
define('E','!');

$x = 4;
$t = " Hello World";
$t .= E;
$t .= E;
$t .= E;

print($t);

Output:

 Hello World!!!

Changed Output:

 Hello World! Hello World! Hello World! Hello World!

(Note: both outputs include a leading space)

\$\endgroup\$
5
  • \$\begingroup\$ Please refer to the formatting guide (Byte count is missing) ;) \$\endgroup\$
    – Beta Decay
    Commented Aug 12, 2015 at 12:04
  • \$\begingroup\$ @BetaDecay sorry, I missed that! Usually I omit that from non-golfed code and completely missed it in the rules! \$\endgroup\$ Commented Aug 12, 2015 at 12:14
  • \$\begingroup\$ It's fine by me :-D \$\endgroup\$
    – Beta Decay
    Commented Aug 12, 2015 at 12:15
  • \$\begingroup\$ Crack attempt #2 \$\endgroup\$ Commented Aug 12, 2015 at 12:36
  • \$\begingroup\$ @NathanMerrill You got it! \$\endgroup\$ Commented Aug 12, 2015 at 12:43
2
\$\begingroup\$

Cracked

Lua, 54 Bytes

G={string="gs_hSDrGSFG5;U*ts"}
print(tostring(G.string))

Current output:

gs_hSDrGSFG5;U*ts

Desired output:

23

Note: I'm not exactly sure why, but if you are using an online compiler (specifically repl.it) the correct output will be 15.

\$\endgroup\$
9
  • \$\begingroup\$ Could you post which environment you're using that achieves 23? I can get 15 in lots of different ways on repl.it and lua53.exe. \$\endgroup\$ Commented Aug 12, 2015 at 18:39
  • \$\begingroup\$ Lua 5.2 on Windows 7. Don't think it makes a difference, but installed through LuaRocks. \$\endgroup\$
    – Nico A
    Commented Aug 12, 2015 at 18:48
  • \$\begingroup\$ This might give it away, but the way you tell is this program: t = {} print(t) If it says table: 0000000(random numbers) then the correct answer is 23, if it says 0x(random stuff) the correct answer is 15. \$\endgroup\$
    – Nico A
    Commented Aug 12, 2015 at 18:52
  • \$\begingroup\$ Hmm. Well, cracked? I'm almost certain the reason the 15/23 difference exists is because the intended solution has to do with pointer size (if you print a table, it prints the memory location); so on a 64-bit system you go from a 8-character pointer to a 16-character pointer; which accounts for the missing (extra?) 8 characters. I'll see if I can figure out what the intended solution was in the meantime, though. \$\endgroup\$ Commented Aug 12, 2015 at 18:52
  • \$\begingroup\$ Actually no, I'm going to edit my code a bit. The only reason you got 15 is because the length of G.string is 15, but the length of G is only 15 because of the Levenshtien distance rule. Sorry about that, I'm going to edit my code. \$\endgroup\$
    – Nico A
    Commented Aug 12, 2015 at 18:53
2
\$\begingroup\$

Cracked

PHP, 21 bytes

Code

print_r(range(i,09));

Original Output

Array ( [0] => 0 )

Changed output

Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 )

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

Fantom, 34

Code

[7115432d/9,219.or(64),37,5555][0]

Original Output

790603.5555555556

Changed output

55

Ok, hopefully this one is a little more competitive than my previous attempt. Levenshtein Distance of 15. Run it in fansh.

Better Code

@isaacg found an easy solution I hadn't even seen. This code removes that solution while keeping the original one I intended, if anyone still wants the challenge.

[7115432d/9,219.or(64),37,55.0f][0]
\$\endgroup\$
4
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – isaacg
    Commented Aug 13, 2015 at 0:39
  • 1
    \$\begingroup\$ This is clearly not my game \$\endgroup\$
    – Cain
    Commented Aug 13, 2015 at 1:35
  • \$\begingroup\$ @Sp3000 I mean the new code I posted is the one to be cracked, without the loophole I missed that isaacg found. \$\endgroup\$
    – Cain
    Commented Aug 13, 2015 at 1:43
  • 2
    \$\begingroup\$ I think it'd be better to make a new answer for that (or you won't show up on the snippet) \$\endgroup\$
    – Sp3000
    Commented Aug 13, 2015 at 1:48
2
\$\begingroup\$

Cracked

Matlab/Octave, 10 bytes

this should be a fairly easy one.

I only tried it with Octave online, but it should run fine in matlab.

Code:

e^(i*pi)+1

Output

0.0000e+00 + 1.2246e-16i

Changed Output

1.9336e+04
\$\endgroup\$
4
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – isaacg
    Commented Aug 13, 2015 at 8:21
  • \$\begingroup\$ @isaacg not the solution i had intended, but it works ;) to keep it short i left out the format long, then using 2 would not match the output. but nevertheless, well done! \$\endgroup\$ Commented Aug 13, 2015 at 8:51
  • 1
    \$\begingroup\$ +e then, I assume? \$\endgroup\$
    – isaacg
    Commented Aug 13, 2015 at 8:58
  • \$\begingroup\$ @isaacg right ;) \$\endgroup\$ Commented Aug 13, 2015 at 9:11
2
\$\begingroup\$

Cracked

Javascript, 169 bytes

Code

a=1,b=a*2,c=a+b,d=[a+b];while(c>b)c-=a;for(i=1;i<=c;i++)d.push(i);i=''+c*d['length']*d['length'];alert(Math[String.fromCharCode(i.charCodeAt(0) * i.charCodeAt(1) / 32)])

Original Output

undefined

Changed output

2.718281828459045
\$\endgroup\$
1
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – Dennis
    Commented Aug 12, 2015 at 16:37
2
\$\begingroup\$

Cracked

Python 2, 57 bytes

Code

i=long;j=map;print reduce(i.__mul__,j(i,j(ord,`i`)))/1234

Original Output

3164217824783520557889

Changed output

9072146982802639849575831250318562874251
\$\endgroup\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Sp3000
    Commented Aug 12, 2015 at 9:52
2
\$\begingroup\$

Cracked

Python 2, 41 bytes

Code

print sum((ord(i)<<0x156 for i in `sum`))

Original Output

19718712710133388269747721838124583424582966957653854505259504044885223633870136963133245450763229047291904

Changed output

20
\$\endgroup\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Sp3000
    Commented Aug 12, 2015 at 12:15
2
\$\begingroup\$

Cracked

MATLAB / Octave, 33 bytes

Code

eig(cov(reshape(sin(1:60),5,[])))

Original Output

ans =

   -0.0000
   -0.0000
   -0.0000
   -0.0000
   -0.0000
   -0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    2.4410
    4.5766

Changed Output

ans =

    0.0064
    0.0000
    0.0000
   -0.0000
   -0.0000
    0.0000
\$\endgroup\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Luis Mendo
    Commented Aug 12, 2015 at 22:44
2
\$\begingroup\$

Cracked

MATLAB / OCTAVE, 28 bytes

Code:

f=@(x)x^.7;g=@(x)7/f(x);g(7)

Original output:

ans =

    1.7928

Changed output

ans =

  -0.3011 - 0.4144i
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Cracked \$\endgroup\$
    – rayryeng
    Commented Aug 12, 2015 at 19:20
2
\$\begingroup\$

Cracked

Clojure, 35 Bytes

Code

(printf "%d\n" 2155263413256326162)

Original Output

2155263413256326162
nil

Changed output

3681347803529195
nil
\$\endgroup\$
1
2
\$\begingroup\$

Cracked

GolfScript, 4 bytes

9,!9

Original output

09

(trailing linefeed)

Modified output

0123456789012345678

(no trailing linefeeed)


If you test your code in Web GolfScript, you have to look at the source code of the output, since the (lack of a) trailing linefeed will be undetectable in the rendered page. For the correct solution, there should be no linefeed between 0123456789012345678 and </textarea>.

It might be easier to use the Ruby interpreter for this one.

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

Cracked

CSS, 53

Code

body:after{counter-reset:a 512;content:counter(a)"₽"}

Original Output

512₽

Changed output

0%

Snippet

body:after{counter-reset:a 512;content:counter(a)"₽"}

\$\endgroup\$
5
  • \$\begingroup\$ "The changed output must have a Levenshtein Distance of 15 or more from your original output." \$\endgroup\$
    – Jakube
    Commented Aug 14, 2015 at 9:19
  • \$\begingroup\$ @Jakube, ok, I'll think about a fix. Anyway, there is no common symbols in input and output and it's impossible to only change output directly without getting my idea. \$\endgroup\$
    – Qwertiy
    Commented Aug 14, 2015 at 9:40
  • \$\begingroup\$ Cracked and unfortunately i don't think a high enough distance is possible because counter-reset maxes at 2417483647 \$\endgroup\$
    – SLuck49
    Commented Aug 14, 2015 at 12:34
  • \$\begingroup\$ I was wrong, it is possible if you add multiple counters like so body:after{counter-reset:a 2417483647;content:counter(a)counter(a)"₽"} \$\endgroup\$
    – SLuck49
    Commented Aug 14, 2015 at 12:40
  • \$\begingroup\$ @SLuck49 Your "cracked" link is wrong. \$\endgroup\$
    – isaacg
    Commented Aug 14, 2015 at 19:57
2
\$\begingroup\$

Mathematica, 35 bytes (safe)

Code

z=Zeta[4/3,1/2];N[Min[z,Sec[z]],20]

Original Output

1.4508303658284314991

Changed output

-0.72451364607415832407

Edit: Note that the original code will sort-of work on Wolfram Alpha, but the modified code does not.

Changed Code

z=Zeta[4/3,1/2];N[Sin[z,Set[z]],20]

Set[z] evaluates to Sequence[] so Sin[z,Set[z]] = Sin[z]. Moreover, Mathematica evaluates function arguments serially and in order, so Set[z] is evaluated after the value of z is already used.

\$\endgroup\$
4
  • 5
    \$\begingroup\$ I hate seeing answers in Mathematica, since it's a proprietary language. There's no way for us to test it if we don't pay for it. \$\endgroup\$
    – mbomb007
    Commented Aug 13, 2015 at 19:49
  • 1
    \$\begingroup\$ @mbomb007 Many people on PPCG do have a copy of Mathematica. If you don't, then you can simply scroll past my answer. \$\endgroup\$
    – jcai
    Commented Aug 13, 2015 at 20:00
  • \$\begingroup\$ Sometimes they work on WolframAlpha. \$\endgroup\$ Commented Aug 13, 2015 at 20:37
  • \$\begingroup\$ @mbomb007 - MATLAB is as well, but I don't see people complaining about it. Octave is not a full replacement to MATLAB, much like Wolfram Alpha isn't a replacement for Mathematica. I like seeing Mathematica code because it's cool to see how some minor changes gives you extraordinarily different output. \$\endgroup\$
    – rayryeng
    Commented Aug 14, 2015 at 15:14
2
\$\begingroup\$

Cracked

APL, 5 characters

3⍟877

Current output

6.1682424839682115

Modified output

0.20016493054644696

An edit distance of 16.

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

Python 2/3, 70 bytes (safe)

Code

x=932436
for i in range(99**4):x=(1103515245*x+12345)%2**31
print(x*x)

Original Output

211455574532454121

Changed output

1039038861760158249

Solution

x=9372436
for i in range(59**4):x=(1103515245*x+12345)%2**31
print(x*x)

The solution initializes x to 9372436 instead of 932436, and does range(59**4) instead of range(99**4). As an aside, the solution runs in about 1/10th of the time.

I probably could have made it shorter without making it too much easier, or at all easier.

\$\endgroup\$
8
  • \$\begingroup\$ This is python 3 only, but i assume that using python 2 won't hurt (original code returns (459842989, 459842989)) \$\endgroup\$
    – Blue
    Commented Aug 12, 2015 at 10:17
  • \$\begingroup\$ Oh yea, I doubled the output to conform to the Levenshtein distance rule; forgot it would be a tuple in Python 2. Still, same effect. \$\endgroup\$
    – Cyphase
    Commented Aug 12, 2015 at 10:38
  • \$\begingroup\$ Since you use brackets on the print, I think you should say this is Python 3, for good form \$\endgroup\$
    – Beta Decay
    Commented Aug 12, 2015 at 12:04
  • \$\begingroup\$ Those two parentheses are the only difference between Python 2 only and Python 2/3; the output is slightly different in each, but I don't think that violates any rules; certainly not the spirit of the rules. But if it really is bad form, I guess I'd go with the Python 2 only version to save 1 byte. \$\endgroup\$
    – Cyphase
    Commented Aug 12, 2015 at 12:08
  • \$\begingroup\$ wouldn't print(x*x) work ok too? \$\endgroup\$
    – gnibbler
    Commented Aug 13, 2015 at 14:10

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.