text:
Two Makes All The Difference - Robbers
For the main cops' challenge, click here

NOTICE - This challenge is now closed. Any cracks which are posted now will not be counted on the leaderboard and the accepted answer will not change.

Challenge
Given the original program, its output and the output of the changed program, you have to find out which characters need to be changed, removed or added to get the expected output.
When you crack someone's code, leave a comment with a link to your crack on their answer.
Formatting
# [<language>, <username of program owner>](<link to answer>)

## Description

<description of change and how you found it>

## Code

<changed code>

Winning
The person who has cracked the most solutions wins.
Leaderboard
13 cracks:

Dennis

8 cracks:

Alex Van Liew

5 cracks:

Sp3000
isaacg

3 cracks:

Luis Mendo
jimmy23013
Dom Hastings

2 cracks:

mbomb007
Sluck49

1 crack:

TheNumberOne
Jakube
ProudHaskeller
David Zhang
samgak
paul.oderso
rayryeng
mgibsonbr
n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳
Stewie Griffin
abligh

@mbomb007 Can you refrain from editing this post, because it makes it harder for me to know where I am when updating the leaderboard

CJam, by Mauris
Description
Mauris' original code does the following:
"f~"     e# Push that string on the stack.
    :i   e# Cast each to integer. Pushes [102 126].
      :# e# Reduce by exponentiation. Pushes 102^126.

No other of CJam's mathematical operators would yield a number that large for small inputs, so :# cannot be modified. Since #, when used for exponentiation, only takes integers as input, :i cannot be removed as well. This leaves only one place to modify the input: the string "f~".
No matter how many characters the string holds, the result will be a left-associative power tower. CJam supports characters in the range from 0 to 65535 (with the exception of surrogates), so we have to express the output as bn×k×j, where b, n, k and j are integers in that range.
The decimal logarithm of the integer that results from the modified code is slightly smaller than log10(2.44×10242545) = log10(2.44) + 242545, so we can divide this value by the logarithms of all possible bases to find proper values for n×k×j.
In fact:
$ cjam <(echo '65536,2>{2.44AmL242545+1$AmL/i:I#s8<"24399707"=}=SIN')
5 347004

Comparing the first 8 digits turned out to be sufficient.
This means that we can express the output as 5347,004 = 1562557,834 = 1259×102×126, so it suffices to replace "f~" with "㴉" or "}  f~".
Code
"㴉":i:#

or
"}  f~":i:#

Note that the spaces in the ASCII code should actually be a tabulator.
Attempting to execute this code in the online interpreter is probably a bad idea, but here's how you can verify the results from the command line:
$ wget -q https://bpaste.net/raw/f449928d9870
$ cjam <(echo '[15625 57834]:c`":i:#") > mauris.cjam
$ cat mauris.cjam; echo
"㴉":i:#
$ cjam mauris.cjam | diff -s - f449928d9870
Files - and f449928d9870 are identical
$ echo -en '"}\tf~":i:#' > mauris-ascii.cjam
$ cat mauris.cjam; echo
"}  f~":i:#
$ cjam mauris-ascii.cjam | diff -s - f449928d9870
Files - and f449928d9870 are identical

One does not simply beat Dennis in CJam

How did you figure out what numbers to use?

@AlexVanLiew Brute force. I'm currently writing an explanation. I just wanted to get the crack posted before somebody else did.

@Dennis: Fair enough. I was trying this one but I don't know CJam; I figured the intended solution involved actually using ~f somewhere in the program.

I hadn't really accounted for Unicode characters -- the PPCG tradition seems to be to count bytes, not characters. As such, there's a solution that doesn't use any. I suppose this counts, though? I'll let the OP decide.

@Mauris The question says when just two characters in the program are changed (emphasis mine), so I assumed this was OK. Anyway, factorizing the number was the hard part.

Hooray, you found it! Very nice job.

@AlexVanLiew I've edited my answer.

@Dennis: Very cool.

Ruby, histocrat
Description
Changed x to be an array instead of scalar by adding *
Changed the last 9 to be a string instead of a number by adding ?
The result is made of an array with a single element ([9]) multipled 9 times then imploded with "9" as separator.
Code
x=*9;puts x*9*?9

Python 2, muddyfish
Description
Through trials and tribulations involving factorizing large numbers and looking for consequtive factors, I realized that changing the 87654 to 58116 would be enough. Then, I factorized 58116 as 87*668. Then I realised that 01234 = 668, so I just needed to change 87654 to 87 and remove the 01234 entirely. This is accomplished with a comment.
Code
print (sum(range(054321)*9876)*87)#654)/01234

Yep, almost exactly how I had it (Mine was print sum(range(054321)*9876)*87#654)/01234)

Clever clever! I'm glad someone got it, and that it was more interesting than "play with numbers"!

Shakespeare, AboveFire
In Scene III, one has to change Claudius into Claudio in the following snippet:
[Enter Claudio]

Claudius:
 Thou art as stupid as the sum of thee and the product of the
 product of me and Helen and Helena

[Exeunt]

Modified code:
The Hidden Change.

Helen, a young woman with a remarkable patience.
Helena, a likewise young woman of remarkable grace.
Claudio, a remarkable man much in dispute with Claudius.
Claudius, the flatterer.
The Archbishop of Canterbury, the useless.

          Act I: Claudius's insults and flattery.

          Scene I: The insulting of Helen.

[Enter Claudius and Helen]

Claudius:
 Thou art as hairy as the sum of a disgusting horrible fatherless
 dusty old rotten fat-kidneyed cat and a big dirty cursed war.
 Thou art as stupid as the product of thee and a fat smelly
 half-witted dirty miserable vile weak son.

[Exeunt]

          Scene II: The complimenting of Helena.

[Enter Claudio and Helena]

Claudio:
 Thou art the sunny amazing proud healthy peaceful sweet joy.
 Thou art as amazing as the product of thee and the pretty
 lovely young gentle handsome rich Hero. Thou art as great
 as the sum of thee and the product of a fair golden prompt good honest
 charming loving noble king and a embroidered rich smooth golden angel.

[Exeunt]

          Scene III: The insulting of Claudio

[Enter Claudius and Helen]

Helen:
 Thou art as stupid as the sum of the sum of thee and a cat and me.
[Exit Helen]

[Enter Claudio]

Claudio:
 Thou art as stupid as the sum of thee and the product of the
 product of me and Helen and Helena

[Exeunt]

          Scene IV: The Final Countdown

[Enter The Archbishop of Canterbury and Claudius]

Claudius:
 Thou art the sum of you and a cat.

The Archbishop of Canterbury:
 Am I better than a fine road?

Claudius:
 If not, let us return to the insulting of Claudio.

[Exit The Archbishop of Canterbury]

[Enter Claudio]

Claudius:
 Open your heart!
 Open your heart!
[Exeunt]

Using the compiler linked by @AboveFire, this prints 11.

Can you please make it more clear which characters were changed? It's not exactly easy to see looking back and forth.

Damn, 15 minutes late. Congratulations.

Jeebus H. Christ. Nice job!

I figured it had to be something like that; it seemed unlikely (and downright cruel) to make the two characters in a noun or adjective somewhere. Somehow, though, I think the poeticism is much better in the original...

I am damn sad :'( I put the names of the variables similar to lead you on a wrong track. I was sure I made it so it was only possible in the way I designed it, but you found another way... Well you got it xD I confirm that you cracked the code successfully.

@mbomb007 I hope my edit made it clearer. AboveFire: sorry :)

@plannapus Haha, it's okay, but the intended way to clear it was to replace the word "king" by "pig".With this change, Helena was equal to 0 and "the sum of thee and the product of the product of me and Helen and Helena" was equal to 1. I had made a list of all words that could be inverted with two letters and used a lot of them in my code(ex: joy->hog->son, war->cat, road->toad, Hero->Hell, curse->purse, helen->helena, claudio->claudius and many others) The only things that can change a Shakespeare program with 2 char is the change of a variable, the change of a noun and the change of a goto.

That was way trickier indeed :)

Good work.
its nice to see I too was on the right track when i gave it a try :) - again, good work @plannapus

Prolog, Fatalize
Description
Add two \s. \ is bitwise negation and \/ is bitwise or.
Code
X is \1\/42.

Correct solution

MATLAB/OCTAVE, Stewie Griffin
A simple bit of complex arithmetic.
acos(i)

C, LambdaBeta
Description
Turn main(a,_) into main(_). The first argument of main is argc which is initialized as 1.
Code
main(_){puts(_*_-1||_*_*_-1||_*_*_*_-1?"Expected Output":"?");}

That's the solution I had in mind. Nice catch. Incidentally if the argv happens to be loaded into memory cell 1 this will not work. I just can't think of any system that would do that that can also run the various interpreted languages on that page.

Python 2, rp.belrann
Change the outermost list comprehension into a set comprehension. Partial credit to @mbomb007, who eliminated all of the "boring" solutions (swapping x and y around, tweaking operators, changing the range).
'~'*sum({(x,y)[x%2] for x in[y for y in range(8)]})

Explanation:
In the original, [(x,y)[x%2]for x in[y for y in range(8)]] generates the following list:
[0, 7, 2, 7, 4, 7, 6, 7]

This is because in Python 2.7, the y in the inner list comprehension leaks into the enclosing scope at it's last known value (which, at the end of a range, is 7). So, in the tuple, y is always 7. x, however, goes through the list as normal, ranging from 0 to 7. When x is even, it chooses the value of x, when it's odd, it chooses y (which is always 7). I noticed that if I included exactly one 7 and all the rest of the values of x, I got 19; then I realized that I could transform the outer comprehension into a set comprehension, which would eliminate all duplicate values and leave me with exactly 19.
This was pretty clever, I don't think I've ever used a set comprehension before. Kudos.

nope. That's not it. print len('~'*sum([(x,y)[x%2]for x in[y for y in range(6)]])) returns 21. Just assign the code to a variable then print if it equals the string you want. If you see True, you cracked it.

Bizarre. _ betrayed me, I guess.

@mbomb007 I got it.

You got me. Well done.

Jonas, Matlab/Octave
Description
I noticed the answer was i^pi, so then I justed had to turn sin into a nop.
Code
0i+(i^pi)

s -> 0, n -> +

Nicely done sir.

Very well done!!

Bash, Dennis
Original code:
echo {{{1..9}}}

Original output:
{{1}} {{2}} {{3}} {{4}} {{5}} {{6}} {{7}} {{8}} {{9}}

Modified code:
echo {,{1..9},}

Modified output:
1 2 3 4 5 6 7 8 9

Explanation:
In Bash you can output a comma separated list of items inside a pair of braces, like this:
echo {a,b,c}

prints
a b c

So the modified code is printing out a list of nothing, the numbers 1..9, nothing.

MATLAB, Luis Mendo
Original code:
-sin(2:.5:3)
ans =
   -0.9093   -0.5985   -0.1411

New answer:
psi(2:.5:3)
ans =
    0.4228    0.7032    0.9228

Description:
Changed -sin to psi, the polygamma function in MATLAB. The - sign is substituted by p and the n is removed.

Brainfuck, Kurousagi
Description
Remove the first > and change the first < to .
Tested at brainfuck.tk. Note that the output doesn't match Kurousagi's post exactly, due to SE eating up unprintable characters.
Code
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[>.+<-]

@muddyfish I linked this answer in my second comment, but I'm still awaiting confirmation from Kurousagi

C, LambdaBeta
Description
Change -1 into *0 so that the result of the multiplication is 0 (a falsy value).
Code
main(a,_){puts(_*_*_*_*_*0?"Expected Output":"?");}

Oops, looks like I introduced a (security flaw?) during my golfing. I'll idly mull it over to see if I can fix it. Nice catch though.

Fantom, Cain
Security through obscurity is a very poor form of security (especially when the two methods are right next to each other in the Fantom docs and anyone who knows what a float looks like will immediately know what to do).
Float.makeBits32(1123581321)

You got me by 1 min !!! well played

Haha you got me, enjoy the free crack

@Cain Was that intentional o.o

@BassetHound I mean, it was more of a social experiment, to see if people would bother learning some obscure language for the crack. I should have made it harder though, to take some actual work.

CJam, by Basset Hound
25me

Calculates e25. Try it online.
The online interpreter gives a slightly different result in my browser, which seems to be a rounding issue.
The Java interpreter prints 7.200489933738588E10, which is the desired output, but in a different format.

Hehe, it was easy. Especially for a CJam god. Correct.

Python 2, Sp3000
Description
Changed 01234 to 0x1234 and min to 9in.
The fact that 4669 = (01234-1)*sum(m<<m in R for m in R) is misleading.
Code
R=range(0x1234);print sum(m<<9in(m,n)for m in R for n in R)

Nicely done! I had m<<m in(m,n), but the main thing was to change the min to in.

MATLAB / Octave, Stewie Griffin
Description
This required negating the input into the anonymous function g, as well as changing the scaling factor of the g function to 2 instead of 7:
Code
>> f=@(x)x^.7;g=@(x)2/f(x);g(-7)

ans =

  -0.3011 - 0.4144i

Thanks for your comment on my (now deleted) answer. I posted a new (very similar) one that can be cracked using WolframAlpha. I believe it's fairer.

Perl, abligh
Description
Add in string repetition operator, x and insert additional digit!
Code
print sin 95x7

Java, TheNumberOne
Description
The program is a one-off implementation of Random.next() with a initial seed of Integer.MAX_INT and all the hex numbers converted to decimal. Changing the seed to the complement of MAX_INT generates the output:
class T{public static void main(String[]a){System.out.print(((~Integer.MAX_VALUE^25214903917L)&281474976710655L)*25214903917L+11L&281474976710655L);}}

(since there must be exactly two changes, pick any sort of no-op change: adding a space somewhere, an extra semicolon, etc)

Nice, You could have also turned Integer.MAX_VALUE into Integer.MAX_VALUE+1 or Integer.MIN_VALUE

Oh, you know what? I tried +1 but since I was doing it in Python it just rolled over to a long, ahaha. That was my first thought, actually.

Brainfuck, AboveFire
this program is a modification of this code me a cookie answer.
that answer works by first pre-calculating a table of useful ascii codes of useful characters, and then has three conditional statements made up by three loops which are entered to by having a 1 in the correct position.
the start of how i broke the code is that the repeating pattern in the changed output is mostly what is printed if you enter the third loop with the table shifted left.
++++++++++[->++++++++<]>>++++++[-<---------->]<-------[----------->>>-<<+<[->->+<<]]>>>+<<>>>+++[->++++++++++<]>(<)++ .<+++++++++[->>>>>>>++++++++++<+++++<++++++++++++++<++++++++++<+++++<++++++++++<<]++++++++++>>+++++...>++>++>-->+>(>)++++<<<<<<<.<<<[->>>>>>.<<>>>>>.<<<<<.>>>>>.<<<<<>>>.<<<<.>>>>>.<<<<.>>>>>.<<<<<.>>>>.<<<<<.>>>>.<<...>.<<<<<<]>[->>>>>.<<...>>>.<<<<.>>>>>.<<<<...>>>>.<<<<<.>>>>.<<...>.<<<<<]>[->>>>.<<>>>>>>.<<<<<<..>>>.<<<<.>>>>>.<<<<>>>>>>.<<<<<<.>>>>>>.<<<<<<>>>>.<<<<<.>>>>.<<...>.<<<<]

(the additional characters are marked with parentheses)

Python 2, muddyfish
Description
Change << to <> (deprecated version of !=) and 0x156 to 0156, the code point for "n" (which appears 3 times in the length 23 string '<built-in function sum>').
Code
print sum((ord(i)<>0156 for i in `sum`))

JavaScript, by Razvan
Description
The modified output is clearly Euler's natural number, which can be accessed as Math['E'].
By changing '' to '3' and 32 to 36, String.fromCharCode generates the E.
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='3'+c*d['length']*d['length'];alert(Math[String.fromCharCode(i.charCodeAt(0) * i.charCodeAt(1) / 36)])

Yes, that's correct. Still it was actually something deeper but it seems that you could bypass it with this trick. I'll think of something else and I'll come back.

Fantom, Cain
Description
The array indexing is set up already, so I just need to make a 55. Honestly, the hardest part was downloading the language.
Code
[7115432d/9,219.or(64),37,55,55][3]

(Inserted a comma, 0 -> 3)

Well crap, that wasn't the intended solution, my red herring was an actual solution

Shakespeare, AboveFire
NOT CORRECT - sorry :(
Will look further into it when i get home from work
In the original Claudio's value is 1132462081
and Claudius' value is 1
In the final Scene Claudio's value is printed twice,
[Enter Claudio]

Claudius:
 Open your heart!
 Open your heart!

open your heart x2 = print value of the other person on stage (Claudio).
So if you change Claudius to Claudio(2 chars) - the value of Claudius will be printed - which is 1 - twice
The Hidden Change.

Helen, a young woman with a remarkable patience.
Helena, a likewise young woman of remarkable grace.
Claudio, a remarkable man much in dispute with Claudius.
Claudius, the flatterer.
The Archbishop of Canterbury, the useless.

          Act I: Claudius's insults and flattery.

          Scene I: The insulting of Helen.

[Enter Claudius and Helen]

Claudius:
 Thou art as hairy as the sum of a disgusting horrible fatherless
 dusty old rotten fat-kidneyed cat and a big dirty cursed war.
 Thou art as stupid as the product of thee and a fat smelly
 half-witted dirty miserable vile weak son.

[Exeunt]

          Scene II: The complimenting of Helena.

[Enter Claudio and Helena]

Claudio:
 Thou art the sunny amazing proud healthy peaceful sweet joy.
 Thou art as amazing as the product of thee and the pretty
 lovely young gentle handsome rich Hero. Thou art as great
 as the sum of thee and the product of a fair golden prompt good honest
 charming loving noble king and a embroidered rich smooth golden angel.

[Exeunt]

          Scene III: The insulting of Claudio

[Enter Claudius and Helen]

Helen:
 Thou art as stupid as the sum of the sum of thee and a cat and me.
[Exit Helen]

[Enter Claudio]

Claudius:
 Thou art as stupid as the sum of thee and the product of the
 product of me and Helen and Helena

[Exeunt]

          Scene IV: The Final Countdown

[Enter The Archbishop of Canterbury and Claudius]

Claudius:
 Thou art the sum of you and a cat.

The Archbishop of Canterbury:
 Am I better than a fine road?

Claudius:
 If not, let us return to the insulting of Claudio.

[Exit The Archbishop of Canterbury]

[Enter Claudio]

Claudio: << changed Claudius to Claudio
 Open your heart!
 Open your heart!
[Exeunt]

Nope, Claudio value is not 1 xD. Better luck next time.

@AboveFire - crud.. I'll have another look at it when i get home, really thought I had it :(

That was my first guess, too, but I didn't have a chance to try it, yet. Anyway, the only part I didn't understand yet is the one with the archbishop so I'll have a look at that when I get home.

Matlab / Octave, Jonas
Description
In the last line, add ' to transform arg' into the string 'arg', which will then be interpreted as ASCII numbers. And then add another ' at the end to maintain the column format.
The almost unnecessary ' in the original code was the main clue. Also, in restrospect, the fact that arg was defined separately (instead of directly within the sin line) should have looked suspicious.
Code
format long
arg = [.1 .2 .3];
sin('arg'*exp(9))'

VBA by JimmyJazzx
Changed IRR to MIRR and changed 5 to a , so there are 3 parameters.
I found this while looking for how Excel's IRR function works. There was an article: How Excel's MIRR Function Can Fix the IRR Function. That tipped me off. Clever attempt, though. I'd never used VBA before, so that was interesting as well.
Sub q()
Dim a(2) As Double
a(0)=-5
a(1)=10
msgBox MIRR(a,0.2,3)
End Sub

Nice. Technically i added both the M and the , so the middle arg was 0.25 but i think they end up having the same result anyway.    Thought using some finance functions could stump the programmers but was revealed by the documentation. Good job

APL, Mauris
Description
This was pretty much trial and error. I knew I had to insert a ¯ (negative number) and use mathematical functions like ○ (trigonometic) or ⍟ (logarithm) that yield complex number for negative input, or directly insert a J (imaginary part).
After a lot or errors, I finally tried inserting a ¯ before 7 and a ⍟ before /.
Code
-⍟/3⍴15¯7

Try it online in ngn/apl demo, the online interpreter recommended by the cop.
Note that this won't work in, e.g., Dyalog APL, which requires a space before the high minus.

Wow, you just don't stop! :O

APL, Mauris
Description
Unlike the two APL answers I cracked before, the indented output of this one reveals very little about the required changes, so I decided to try a brute force approach.
Two characters aren't enough for loops, so the added characters (if any) had to be parts of numeric literals, mathematical functions or ⍨.
I chose a subset and hoped I'd get lucky. Using this CJam script, I generated all source codes (many of them with syntax errors) at an edit distance of 2 or less that only add character from the chosen set. This yielded 28,014 different potential solutions.
Aside from the online interpreter, ngn/apl is available for NodeJS. It even has a command-line flag (-l) that executes code linewise, which is almost perfect for this purpose.
After a minor change that condensed error output to a single line, I was able to grep the output to find the line number of the correct source code. The interpreter powered through the roughly 28,000 possible solutions in less than 6 seconds.
This sums up what I did:
$ diff apl.js `which ngn-apl`
4806c4806
<                       return e + '\n';
---
>                       return ('' + e).replace(/\n/g, '') + '\n';
$ cjam gen-edit-dist-2.cjam > brute-force.apl
3⍟877
0123456789.¯+-÷×⌈⌊*!|⍟○⊥⊤⍨
$ wc -l brute-force.apl
28014 brute-force.apl
$ time ngn-apl -l < brute-force.apl | grep -n '0\.2001649'
3791:0.20016493054644696
20128:0.20016493054644696

real    0m5.506s
user    0m5.516s
sys     0m0.252s
÷3⍟○77
3⍟⍨○77

This reveals two possible solutions: replacing 8 with ○ and inserting ÷ before 3, or replacing 8 with ⍨○.
Code
÷3⍟○77

or
3⍟⍨○77

Try them online in the ngn/apl demo.1
These modifications calculate 1 / log3 77π = log77π 3, which yields the desired output.

1 Note that the last digit may be a 3 on some machines.

Nice work. But if the digits change from browser to browser that is a huge problem... Maybe jimmy23013's 4 byte APL cop is impossible in some environments simply depending on floating point rounding

This seems to be a simple 32 vs 64 bit issue. jimmy23013's modified code works on my desktop and my phone, so it doesn't seem to have the same issue. Writing truly platform-independent code should pretty much be impossiboe once you involve fixed width floats...

bc, abligh
Merely inserted the math operators. Took about 1 minute to solve once I looked up what bc was and what math operations it had. The first thing I thought of was division, but there weren't common factors that looked nice. So I immediately went for exponentiation and modulus. At least 15 digits were necessary for the modulus b/c of the expected output. After that, I guessed twice and found it.
4518^574%615489737231532

Lua, TreFox
Description
"_G" is the global table, making "_G.load" refer to the global function "load". Converting a function to a string results in returning the function's address, which is then made into the length of the string by the length-operator "#".
Code
G={load="lfkjgGsHjkU83fy6dtrg"}
print(#tostring(_G.load))

Also, since this is my first post on here, I can't make a comment on the original answer.

I've left a comment on the cop answer. By the way, this doesn't quite work for me. The address is I get is 0x321a40c6d0, for a final output of 22.

I am not sure why you are getting 22... on everything  I tested it was 18 or 26.

@Dennis Try it in the official lua demo.

Aha, I was so close! I knew I needed the global load, and I knew _G referred to the global symbol table... I just didn't put the two together.

Python, rp.beltran
Description
I noticed that the needed letters were always 2 in front of a digit. changing the third \w to \d got all of the right letters except the spaces. \D was the only \ group I could find that allowed letters and spaces.
Code
import re;''.join(re.findall('\D(?=\w\d)','t74q joh7 jv f9dfij9j bfjtf0e nnjen3j nnjrb6fgam3gtm5tem3hj s3eim7djsd3ye d5dfhg5un7ljmm8nan3nn6n k m2ftm5bsof5bf r5arm4ken8 adcm3nub0 nfrn6sn3jfeb6n d m6jda5 gdif5vh6 gij7fnb2eb0g '))

w -> D, w -> d in the regex.

Pyth, isaacg
Description
The original code does the following:
 CG      Convert "abcdefghijklmnopqrstuvwxyz" from base 256 to integer, yielding
         156490583352162063278528710879425690470022892627113539022649722.
   ^3y21 Compute 3^(2 * 21).
%        Calculate the modulus.

Since 156490583352162063278528710879425690470022892627113539022649722 - 58227066 gives 156490583352162063278528710879425690470022892627113538964422656, which equals 226 × 3 × 7 × 7477 × 381524422711 × 17007550201751761 × 2288745700077000184147, the desired output can be obtained by replacing ^3y21 with something that evaluates to a divisor of this product and is larger than 58227066.
The ^ in the original code suggests that we might use it to calculate a power of 2, the 3 that we could calculate a fitting divisor of the form 3 × 2n.
Both are misleading. Solutions with a Levenshtein distance of 3 (%CG^2 26, %CG^y2 13, %CG^4y13) or 4 (%CG.<3y13) are readily found, but the solution at distance 2 requires a different approach.
The lowercase alphabet (G) has 26 letters, so its power set (the set of all strictly increasing sequences of lowercase letters) has 226 elements. By replacing y2 with yG, we compute this power set.
We can retrieve the set's length by replacing 3 with l, which leaves us with ^lyG1, i.e., 226 raised to the first power.
Code
%CG^lyG1

Note that this will only work on a computer with enough available memory (roughly 6.43 GiB, according to time), so it will not work with the online interpreter.
Here's how you can verify the results from the command line:
$ \time -v pyth -c '%CG^lyG1'
58227066
        Command being timed: "pyth/pyth.py -c %CG^lyG1"
        User time (seconds): 30.73
        System time (seconds): 2.12
        Percent of CPU this job got: 100%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:32.85
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 6742564
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 0
        Minor (reclaiming a frame) page faults: 2269338
        Voluntary context switches: 1
        Involuntary context switches: 58
        Swaps: 0
        File system inputs: 0
        File system outputs: 0
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0

Correct! Well done.

C++, f41lurizer
Good old trigraphs.
#include <iostream>
int main()
{
    //can you figure it out??/
    std::cout << "I like cake and";
}

g++ won't accept the trigraph without additional compiler flags. Removing the newline should work with all compilers.

Heh, I suppose that does work, huh? I'm pretty sure this was the intended solution, but it doesn't really matter since the original is invalid anyway.

Python 2, muddyfish
Description
Change `i` to `id` = '<built-in function id>' and 1234 to 01234 (octal). Found by recalling the wise words of Sir @xnor (paraphrased): "If you ever need a string that's 22 chars long..."
Code
i=long;j=map;print reduce(i.__mul__,j(i,j(ord,`id`)))/01234

VBA, JimmyJazzx
Description
First of all the call of a(2) was strange since only a(0) and a(1) get used, that was actually a big hint.
Next i looked into what the function IRR really does (see here).
There is no combination of integer a(0) and a(1) that can possibly yield the modified output.
So I looked for combinations of a(0) and a(2) (<- first character changed) that resulted in the desired output and found a(0) = -1 and a(2) = 8. Since multiplying a(0) and a(2) with the same number doesn't change the outcome I simply multiplied both with 5 so a(0) would stay the same.
Code
Sub q()
Dim a(2) As Double
a(0) = -5
a(2) = 40
MsgBox IRR(a, 0.253)
End Sub

Though this may yeild the correct result this is not what I had done. mbomb007 did get what i had done correct.
Good try though and im not sure which one the judge will accept as this one did come in first and ends up with the same result as the real answer.
As for the a(2) that was there to mislead people, as it took the same amount of bytes as a(1) would have. But wanted to keep people away from seeing what IRR really does.

Clojure, Bob Jarvis
Base conversions are fun.
(printf "%d\n" 7r2155263413256326162)

PHP, Ismael Miguel
print_r(range(1,07));

I guess it really was that simple.

Yup, it was that simple. I didn't put that much effort on it, I was just warming up.

PHP could be a great language for this challenge because of all the wonky stuff it's got in there.

Yeah, I think I will come up with something

modern Perl 5, msh210
Description
The s/// call has to only apply to the first element in the @array and using each with the for covers it off!
Code
@array = (qw smiles) x 11;
s/.*// for each @array;
print "@array\n";

Added space in between for and each. I

Works in ideone. You can just add an arbitrary space for the second changed character.

Matlab/Octave, paul.oderso
Description
I took the natural log, and recognized it as near pi ^ 2. From there it was easy.
Code
e^(pi*pi)+2

Added a p, 1 -> 2

MATLAB, Jonas
Description
Change 1+1 to 49+1. I don't actually have MATLAB so I can't test this, but the number looks right
Code
sin(49+1)

yes - thought that's not what I had in mind.

@Jonas: What was the hard solution? Do you mind sharing?

@StewieGriffin: Here's a better version of the question instead: http://codegolf.stackexchange.com/a/54625/18

Ruby, histocrat
Description
Need to make the regex at the end work on the string literal ?9 so we need to make the variable $_ instead of _, also need to start the regex itself. Didn't realise that you could omit the {} when interpolating variables into regex in ruby.
Code
p $_=?9;p$.+=1until /#$./

Confirmed working on ideone (Ruby 2.1.5), but it doesn't work on my machine (Ruby 2.1.5). Odd.

Nice one. works fine for me in ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]

Octave, Daniel
Description
111 is the code point of the ASCII character o, so the desired output can be achieved by replacing cos with "o".
(1) retrieves the first character of the string and *1 casts to integer.
Code
format long;
"o"(1)*1

APL, jimmy23013
Description
The output is obviously 1/9 with rounding errors and the code already contains a ⍟ (logarithm), so using it together with * (exponentiation) seems a natural choice for introducing that error.
In fact, inserting ⍨ between ⍟ and 9, and * between 9 and 9 produces the intended output.
⍨ reverses the arguments of the preceding dyadic function, so this calculates log999 ≈ 1/9 with the intended error.
Code
9⍟⍨9*9

Try it online in the ngn/apl demo.

Matlab / Octave, Jonas
Description
Just change tragic by magic in the second line.
tragic is a symmetric, integer-valued matrix. The difference between both inputs is integer-valued but not symmetric. So a new kind of matrix was needed. The integer values and the name traffic looked familiar.
Code
mistake=-1;tragic=rosser;a=hilb(8)*42;
a(:,:)+magic(8)/mistake

I guess I should have put a call to det in there to make it harder, but I wanted this to remain fun (also, det doesn't easily fit into a sentence)

A magic mistake, eh?

@Jonas Yes, with det it would have been much harder

Wolfram Language Mathematica or WolframAlpha, belisarius
Original Code
8.!

Changed Code
8.^i!

Original Output
40320.

Changed output
2.67182 - 0.891969 I

GolfScript, Dennis
Description
9,:n9 doesn't work because n9 would be one variable name. In GolfScript you usually get rid of this by using a symbol as the variable name, so...
Code
9,: 9

More explanations.

Did... Did you assign something to the space character?

@AlexVanLiew Yes. The full program executed would be 9,:space 9]print space n space print.

That's amazing.

JavaScript, Razvan
Description
Changed 1 to .1 and added a semicolon.
Code
a=(((b=(a=.1)+a)+a)-b-a)*(a=[b]);['length'];
alert(a);

Yes! That's what I had in mind.

PHP, Razvan
Description
Inserted ( and ), so $T_I_(M_E * $A_U_T_U_M_N) executes TAN(M_E * 2), where M_E is Euler's natural number.
Code
$S_U_M_M_E_R = 1;
$A_U_T_U_M_N = 2;
$T_I_M_E = 1;

if ($T_I_M_E == $S_U_M_M_E_R) {
    $A_C_=$T_I_=$O_N= 'SWIM' ? 'TAN' : 'DRINK';
}

print $T_I_(M_E * $A_U_T_U_M_N);

PHP, Dom Hastings
Comment out the first two lines so they all append together.

define('E','!');

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

print($t);

Not quite, I get:  Hello World!tt... UsingPHP 5.4 if that makes a difference... I'll update the other with the version.

Lua, TreFox
In Lua, # is the "sizeof" operator. The discrepancy in the original behavior (15 or 23) is because the solution involves the size of the string created by converting a table to a string, and that string contains the address of the table (which is 16 characters on a 64-bit system and 8 on a 32-bit system). It looks like the particular distribution TreFox has is 64-bit. Also, apparently arguments in Lua work like arguments in Javascript, in which they don't seem to care how many arguments are passed, so changing the . to a , only causes G to be printed.
G={string="gs_hSDrGSFG5;U*ts"}
print(#tostring(G,string))

Secretly, I think this challenge was designed to make you think about skimpy underwear the whole time you were working on it.

Matlab / Octave, rayryeng
Description
Change eig to eigs and sin to sind.
The main clue was that the modified output has six eigenvalues sorted by magnitude, which is what eigs returns.
Code
eigs(cov(reshape(sind(1:60),5,[])))

Very well done! How long did that take you to figure out? :)

It took quite a while... but I see now that the main clue had already been given in Matlab's chat room !

SWI-Prolog, Fatalize
Description
Replace an E for an F (or the other way around) and change a single digit in one of the numbers input.
Code
assert(d(F,F):-(print(E),print(F))). d(123456,123457).

That's not how I did it, but that works nonetheless! Well done. The way I did it was changing d(123456,123456) to dif(123456,123456), to call the builtin predicate dif/2 which returns false if its two arguments are the same.

@Fatalize I really wish I've seen this earlier :P

SWI-Prolog, mgibsonbr
Description
Change , (conjunction) to ; (disjunction).
Add a space to make the distance 2.
Code
assert((o(X,Y,Z):-ABC is X**X; print(ABC))). o(99,y,z).

JavaScript, Razvan
Description
The changed output being 10/3 was a dead giveaway.
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 = 10 / numbers['length'];
alert(infinity);

No worries - I had == in the for loop, but yeah 10/3 was a dead giveaway :)

Correct, I didn't notice this obvious solution.

Pyth, Beta Decay
Description
This one's just obvious.
Code
.!10

77 -> 10

Actually, I went for .!&77T. I guess I didn't really give it much thought ;)

CSS, Qwertiy
Description
After seeing that the first number was a zero what needed changed seemed pretty clear
Code

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

Stuck, Vioz-
Change the first two numbers both to 3.
3R3R3R4R5R6R7R8R9R9z]

Zipping in Stuck works like zipping in Python (I imagine z is backed by zip()), which is the shortest sequence is taken as the max length. Without the ], the output is a list of tuples, and I don't really know what ] does. Pops the list at the top of the stack and pushes everything in it onto the stack, it looks like.
@Vioz-: Particularly for your scipy module, you should make sure that if the numpy or scipy libraries aren't available it doesn't crash with ImportError, but rather defines any methods that module supplies to just raise NotImplementedError or something similar. Also, you probably shouldn't commit .pyc files to your repo.

Nice! My solution was actually 12R3R4R5R6R7R8R9R8z] (remove the first R, change the last 9 to 8). I guess I didn't think of the obvious solution :P. Also, thanks for the tips, I'm sort of new to this whole "my own language thing". ] just pops each element from the top list of the stack and adds it to the stack. I don't think I said that clearly in my explanation.

@Vioz- You'll get the hang of it!

Python, rp.beltran
Description
Changed dis to this.
import this is an easter egg which prints The Zen of Python.
Code
import this
def torun():
 print "hello world"
try:
 print dis.dis(torun)
except:
 pass

Beat me by 30 seconds.

Dang it. I was hoping that trick was more obscure. Good job.

@rp.beltran I mean, if you google "The zen of python"... A more obscure trick I saw in an old cops/robbers was using from __future__ import braces and some clever stuff to extract the string "chance".

Fair point, and I figured it would get cracked pretty quickly. 2 people in 4 minutes though, I'm impressed.

CJam, Basset Hound
Description
Finding the proper changes is easier if we work from the desired output. 5010670554118 looks like an integer in base 8 or higher.
5010670554118Ab8b
S
5010670554118Ab9b

prints 344786655312 1415926558979, and the second group of digits look a lot like the decimal expansion of Pi.
In fact, Ps pushes "3.141592653589793" (Pi cast to string), "3."- (added 3) removes all occurrences of 3 and ., i converts the result to the integer 1415926558979 and 9b (replaced 2 with 9) performs the required base conversion.
Code
Ps"3."-i9b

Try it online.

Yep, that's it...

Perl, Adam Katz
Description
$_=cos 99 saves 0.0398208803931389 in the variable $_. If we multiply this amount by 0x7275, we obtain 1166.79161639936, which is roughly 4 times the original output and 8 times the modified output.1
The original code archives almost-division-by-4 by substituting the first 3 in $_ with a 0 by executing s/[3-8]/0/, which modifies $_ and returns the number of substitutions (1), by which $_ is then divided.2
After noting that there are eight digits between 3 and 8 in the unmodified value of $_, attempting to replace all of them by appending g to s/[3-8]/0/ seemed natural, since this will divide the (modified) value of $_ by the number of substitutions.
Finally, to diminish the effect of the almost-division-by-4, it suffices to replace the first 3 (and all occurrences of 3 and 8 that follow) with a 3 by replacing s/[3-8]/0/ with s/[3-8]/3/.
Code
$_=cos 99;printf"%.14f",0x7275*sin $_/s/[3-8]/3/g

1 The code actually applies sine to $_ before multiplying, but sin x ≈ x when x is close to 0.
2 Again, this completely ignores the sine, which is almost linear near 0.

Python, Beta Decay
Description
Calling math.tan on the desired ouput gives 0.777…, so it suffices to replace tan with atan and 749 with 7/9.
Code
import math, decimal
print(decimal.Decimal(math.atan(7/9)))

The output is actually 0.66104316885068692410953872240497730672359466552734375 on my machine, which rounds the (intermediate) result of math.atan(7/9) differently.

Yep, you got it :D

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Build Me a Pyramid
You need to build a pyramid from cubes. Cubes can be viewed from 2 angles:
  _____        _____
 /\    \      /    /\
/  \____\    /____/  \
\  /    /    \    \  /
 \/____/      \____\/

This is an example for 2-size cubes from the 2 possible angles.
The height of the cubes is $size slashes (or back-slashes), and the width of the cube is 2 * $size underscores. The top level width should contain an extra underscore character.
Input will be provided as a string containing a number (size of cubes), slash or backslash (to indicate direction/angle), and another number (height of the pyramid).
Examples:
Input:
1/1

Output:
 ___
/\__\
\/__/

Input:
1\1

Output:
 ___
/__/\
\__\/

Input:
2/1

Output:
  _____
 /\    \
/  \____\
\  /    /
 \/____/

Input:
1/2

Output:
     ___
 ___/\__\
/\__\/__/
\/__/\__\
    \/__/

Input:
2\2

Output:
  _____
 /    /\
/____/  \_____
\    \  /    /\
 \____\/____/  \
 /    /\    \  /
/____/  \____\/
\    \  /
 \____\/

Input:
1/3

Output:
         ___
     ___/\__\
 ___/\__\/__/
/\__\/__/\__\
\/__/\__\/__/
    \/__/\__\
        \/__/

Trailing/leading whitespaces are OK.
Standard loopholes are disallowed.
You can assume input will always be valid.
You may assume the input won't cause too big output, i.e: no line wrapping when the output is printed to the terminal.
Size of cube & height of pyramid is positive (i.e. ≥ 1)
This is code-golf, so shortest code in bytes wins.

Current Winner is:
Glen O with 270 bytes in julia
challenge stays open. if you beat the current best, I'll update the accepted answer.

Your cubes are different from the ones in recent diamond pattern challenges, in that the top row has 2s+1 underscores, wheras the other challenges had 2s underscores on the top row and 2s-1 on the other rows. That means your horizontal pitch is 3s+1. I guess it's good to mix things around. Just making the observation in case someone misses it.

what are the max values of size and height? can we assume they are one digit?

no, you may not assume it is one digit, but you may assume the provided input won't cause the output to be "too big", i.e. won't cause line wrapping in your terminal.

Julia - 503 455 369 346 313 270 bytes
f=A->(t=47∉A;h='/'+45t;(m,n)=int(split(A,h));W=2m*n+1;X=(l=3m+1)n+m+1;s=fill(' ',X,W);s[end,:]=10;for i=1:n,j=i:n,M=1:m s[M+i*l+[[L=[J=(2j-i)m,J,J-m]+M W-L]X.-[l,m,0] [0 m].+[1,m,m].+[J,J+m,J-m]X-l]]=[1,1,1]*[h 139-h 95 s[i*l,i*m-m+1]=95]end;print((t?s:flipud(s))...))

Ungolfed:
function f(A)
  t=47∉A      # Determine if '/' is in A ('/' = char(47))
  h='/'+45t   # Set h to the appropriate slash ('\\' = char(92), 92=47+45)
  (m,n)=int(split(A,h)) # Get the two integers from A
  W=2m*n+1    # Get number of rows of output (vertical height of pyramid)
  X=(l=3m+1)n+m+1 # Get columns of output + 1 (for newlines)
  s=fill(' ',X,W) # Create 'canvas' of size X x W
  s[end,:]=10 # Put newlines at end of each output row
  for i=1:n, j=i:n, M=1:m
    # This is where the fun happens.
    # K and L represent the shifting points for '/' and '\\' in the
    # horizontal and vertical directions.
    # They are used to make the code neater (and shorter).
    K=M+i*l-[l,m,0]
    L=[J,J,J-m]+M
    # The next two assign the slashes to appropriate places
    s[K+L*X]=h
    s[K+(W-L)X]=139-h
    # This one puts the first 2m underscores in each of the underscore sets
    s[M+i*l-l+[0 m].+[1,m,m].+[J,J+m,J-m]X]=95
    # This places the final underscores on the top edges (repeatedly)
    s[i*l,i*m-m+1]=95
  end
  # The above produces the array orientation for backslash, but uses
  # the "wrong" slashes along the diagonals if there's a forward slash.
  # This line flips the matrix in that case, before printing it.
  print((t?s:flipud(s))...))
end

Usage:
f("3/2")

or
f("2\\3")

Perl, 343 bytes
$_=<>;$_=~/(\d+)(\S)(\d+)/;$v=$2eq'/';$w=$1*3+1;for$y(0..$1*2*$3){$k=$w*$3+$1-1;for$z(0..$k){$x=$v?$k-$z:$z;$q=($y+$1-1)/$1|0;$r=$x/$w|0;$d=$q+$r&1;$f=($y-1)%$1;$f=$1-$f-1if$d;$g=($x-$f)%$w;$u=$r;$q=2*$3-$q+1,$u++if$q>$3;print(($q>=$r&&$q&&$g==0)||($q>$r&&$g==$w-$1)?$d^$v?'/':'\\':$q>=$u&&$y%$1==0&&$g>0&&$g<($w-$1+($q==$r))?"_":$")}print$/}

Multiline with comments:
$_=<>;$_=~/(\d+)(\S)(\d+)/;$v=$2eq'/'; # read input
$w=$1*3+1; # compute width of each cube in chars
for$y(0..$1*2*$3){$k=$w*$3+$1-1;for$z(0..$k){ # iterate over rows, columns
    $x=$v?$k-$z:$z;   # flip x co-ordinate based on 2nd param
    $q=($y+$1-1)/$1|0;$r=$x/$w|0;   # parallelogram row and column index
    $d=$q+$r&1;  # flag parallelogram as left or right leaning
    $f=($y-1)%$1;$f=$1-$f-1if$d;  # compute a zig-zag offset
    $g=($x-$f)%$w;  # compute column position, offset by zig-zag
    $u=$r;$q=2*$3-$q+1,$u++if$q>$3; # vertical threshold for printing chars
    print(($q>=$r&&$q&&$g==0)||($q>$r&&$g==$w-$1)?$d^$v?'/':'\\': # output slash
    $q>=$u&&$y%$1==0&&$g>0&&$g<($w-$1+($q==$r))?"_":$") # underscore or space
}print$/}   # print out newline at end of row

Example output:
2/3
                _____
               /\    \
         _____/  \____\
        /\    \  /    /
  _____/  \____\/____/
 /\    \  /    /\    \
/  \____\/____/  \____\
\  /    /\    \  /    /
 \/____/  \____\/____/
       \  /    /\    \
        \/____/  \____\
              \  /    /
               \/____/

I also tried implementing it as a C function using the same algorithm, hoping to save bytes from the luxury of single-character variable names, but it ended up 15 bytes larger, at 358 bytes (needs to be compiled with -std=c89 under gcc to leave off the void in the function header):
j(char*s){int c,p,v,x,y,k,z,u,g,w,r,d,q,f;char e;sscanf(s,"%d%c%d",&c,&e,&p);v=e=='/';w=c*3+1;for(y=0;y<=c*2*p;y++){k=w*p+c-1;for(z=0;z<=k;z++){x=v?k-z:z;q=(y+c-1)/c;r=x/w;d=q+r&1;f=(y+c-1)%c;if(d)f=c-f-1;g=(x-f)%w;u=r;if(q>p){q=2*p-q+1;u++;}printf("%c",(q>=r&&q&&g==0)||(q>r&&g==w-c)?d^v?'/':'\\':q>=u&&y%c==0&&g>0&&g<(w-c+(q==r))?'_':' ');}printf("\n");}}

You should be able to get most, if not all those 15 bytes back on the C version: printf("%c" --> putchar( ,  printf("\n") --> puts("") , move all int declarations outside the function, then you can eliminate the int  (see http://meta.codegolf.stackexchange.com/q/5532/15599), change all character literals for their ascii codes eg ' ' --> 32. Refactoring your for loops eg for(k+1;z--;) can also help but is trickier.

Also I think e can be an int provided you initialize it to zero. sscanf  will only overwrite the least significan byte and may leave any existing garbage in the other three bytes.

finally I think a full program will go better than a function in this case. You gain three extra characters from main instead of j but you don't have to  pass parameter s around, and you can take advantage of automatic initialization of global variables.

Ruby, 332
The only golfing done so far is elimination of comments and indents. I will golf later.
gets.match(/\D/)
d=$&<=>"@"
n=$`.to_i
m=2*n
p=$'.to_i
a=(0..h=4*n*p).map{' '*h*2}
(p*p).times{|j|
x=h-j/p*(3*n+1)*d
y=h/2+(j/p-j%p*2)*n
if j%p<=j/p
(-n).upto(n){|i|
a[y+i][i>0?x+m+1-i :x-m-i]=?/
a[y+i][i>0?x-m-1+i :x+m+i]='\\'
a[y+n][x+i]=a[y-n][x+i]=a[y][x-d*(n+i-1)]=?_
a[y+i+(i>>9&1)][x+d*i.abs]='\_/'[(0<=>i*d)+1]
}
end
}
puts a

I set up an array of spaces and poke the individual characters into it. There is quite a lot of overdrawing both of one cube on top of another (work from bottom to top) and within the cube itself, to avoid extra code. I make the pyramid by drawing a rhombus (similar to https://codegolf.stackexchange.com/a/54297/15599) and surpressing the top half.
The hard part was drawing the scalable cube. I started off with a perimeter hexagon with 2n+1 _characters on the horizontal sides. I also had had 2n+1 / and \ ,so I had one too many, but by plotting the _ last I overwrite them.
The internal lines are the only ones that are changed depending on the direction the cube is facing. I plot all the / and \ with a single assignment. abs helps reverse the direction, and i>>9&1 adds an extra 1 to the negative values of i, which lowers the top part down. for i=0 one of the required _ is overplotted, so the selector string '\_/' contains all three symbols, selected according to the sign of i.
The whitespace around the output is ample but not excessive: 4*p*n high and 8*p*n wide (the latter is to enable the apex cube to always be in the centre of the output.) I understand "trailing / leading whitespaces" to include whole lines, but can revise if necessary.
Ungolfed code
gets.match(/\D/)                                   #find the symbol that is not a digit. it can be extracted from $&
d=$&<=>"@"                                         #direction, -1 or 1 depends if ascii code for symbol is before or after "@"
n=$`.to_i                                          #side length extracted from match variable $`
m=2*n
p=$'.to_i                                          #pyramid height extracted from match variable $'
a=(0..h=4*n*p).map{' '*h*2}                        #setup an array of h strings of h*2 spaces

(p*p).times{|j|                                    #iterate p**2 times
  x=h-j/p*(3*n+1)*d                                #calculate x and y coordinates for each cube, in a rhombus
  y=h/2+(j/p-j%p*2)*n                              #x extends outwards (and downwards) from the centre, y extends upwards

  if j%p<=j/p                                      #only print the bottom half of the rhombus, where cube y <= cube x
    (-n).upto(n){|i|                               #loop 2n+1 times, centred on the centre of the cube
      a[y+i][i>0?x+m+1-i :x-m-i]=?/                #put the / on the perimeter of the hexagon into the array
      a[y+i][i>0?x-m-1+i :x+m+i]='\\'              #and the \ also.
      a[y+n][x+i]=a[y-n][x+i]=a[y][x-d*(n+i-1)]=?_ #plot all three lines of _ overwriting the / and \ on the top line
      a[y+i+(i>>9&1)][x+d*i.abs]='\_/'[(0<=>i*d)+1]#plot the internal / and \ overwriting unwanted _
    }
  end
}
puts a

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
join lists by common elements
You have N lists
A = [5, 6, 10, 15]
B = [3, 0, 7, 4]
C = [49, 59, 29]
D = [19, 29, 39]
E = [9, 15, 3, 10]

You have to combine them such that:
Two lists which have a common elements they should be next to each other. In this case answer is:
A,E,B,C,D
[5, 6, 10, 15, 9, 3, 0, 7, 4, 49, 59, 29, 19, 39]

E comes after A as they have 2 common elements. After E the B comes as they have common elements. B do not have common elements with C or D so anything can come (C or D), lets say C comes. Now C should be followed by D as they have common elements.
Note: This is also acceptable solution
B,E,A,C,D
C,D,A,E,B
....

Thus the main condition is if two lists have common elements they should be next to each other.
Note 2: For simplicity we assume a list can have common elements with maximum 2 other lists. However there can be list which have no  common elements with any other list.
Note 3: Output format : preferably both, the name of list and the number sequence.

What exactly are the input and output formats? Is the output A,E,B,C,D or the list of numbers? is it always a single letter identifier before the equals? Please clarify.

@isaacg  output format can be A,E,B,C,D . Does the identifier of list matter !! If so yes it can be more then one letter

Sometimes this is not possible. What to do then?

I think you'll have to specify if the number sequence is required or not. Or give a bonus for outputting the number sequence. For a code golf contest, "preferably" is too vague. Also, if the number sequence is involved, I don't see a clear definition of what it is. I think I understand it based on the example (common elements are only listed once, between the two lists?), but a more formal definition would be useful. But if it's purely optional, you might just as well remove it completely.

CJam, 47 44 bytes
q~]e!{_2ew[{~_,@@\-,-}/]:+_W>{:W;:L}&}/];L:p

Explanation:
                                             e# L = [], W = -1
q~                                           e# Evaluate input
  ]                                          e# Wrap in array
   e!                                        e# Push all unique permutations
     {                               }/      e# For each permutation:
      _2ew                                   e#   Push all overlapping slices of length 2
           {         }/                      e#   For each slice:
            ~_,@@\-,-                        e#     Push number of common elements
          [            ]:+                   e#   Sum the number of common elements from all the slices
                          _W>{     }&        e#   If sum > W:
                              :W;            e#     Assign sum to W and pop off the stack
                                 :L          e#     Assign the permutation to L
                                       ];    e# Clear the stack
                                         L:p e# Print each list in L

Try it online.


text:
Non-repeating random numbers
Find the shortest way to generate a random number between 0-9 without repeating the last generated number.  Here is an example written in javascript.
var n=t=0;
while(n==t){
  t=Math.floor(Math.random()*9);
}
n=t;

I don't know if it is possible, but it would be interesting if there is a solution using only one variable.
To clarify the solution can be in any language. Based on the comments I am going to disallow using arrays since apparently that makes it very easy and this is code-golf so the shortest answer wins.

Nope. Interesting would be using only one scalar variable and no stack, nor register.

@qw3n - Can you clarify here? Are answers in all languages acceptable? Are you interested in simply the shortest code.

Also, as noted in the first comment, this is super trivial if that one variable is an array.

@Optimizer to explain why I asked the question here instead of SO. I felt there was a clear and simple way to solve the problem (similar to the sample code I have). But I felt that it would be an interesting challenge to see if it could be done in a much shorter way, but not necessarily a way that would be wise to add to an actual codebase. If the question needs to be closed that's fine just wanted to give my point of view.

This is pretty much a simplification of this old question.

Pyth, 7 bytes
e=+ZhO9

Try it online: Demonstration
Explanation
          implicit: Z = 0
     O9   Generate a random int from [0, 1, ..., 8]
    h     add 1
 =+Z      add this to Z and update Z
e         print Z modulo 10

I don't think this is correct. You would need your list to include 9 in order for it to be random. Otherwise, each time you can name a number that you know it won't be, once you've seen the previous random number.

@mbomb007 h adds 1 to the generated number, so the real range is [1, ..., 9].

@Dennis Yeah, but it has to be from 0 to 9 as per the OP's question, or am I reading it wrong? Yeah... nvm. I think I read it as inclusive, but just realized that the program he gave multiplies by nine which is exclusive.

@mbomb007 If you add 0 to the previously generated integer, you get the same integer again, which is precisely what you're trying to avoid.

@mbomb007 this is the way I've always done it. The first iteration is guaranteed not to contain a 9, but after that it's simply guaranteed to not contain the number from the previous iteration, which is what the OP wants. If it's essential that all ten digits must be able to appear in the first call, followed by no repetitions after that, just call the random number generator once or twice to randomise it, then on the next call it can give any digit.

CJam, 10 8 bytes
Thanks @Dennis for a 2 bytes golf!
You can repeat this piece of code how many times you want.
A,W-mR:W

Explanation:
         e# At startup, W = -1
A,       e# Push [0 ... 9]
  W-     e# Remove W from the list
    mR   e# Random choice from list
      :W e# Assign to W
         e# The number is left on the stack

Try it online.

Actually you cannot run it multiple times as context is not saved between different runs, so W's value remains -1 at beginning of each run. However, you can repeat the code multiple times to get more than 1 random number

@Optimizer That's what I meant (and what the online test does). I guess I wasn't very clear, let me edit that :)

You can use mR instead of mr0=.

@Dennis Missed that in the docs, thanks.

K5, 19 bytes
Not particularly clever:
t:-1;r:{t::*1?10^t}

Each time r is invoked, it picks 1 random number (*1?) from the set formed by taking the range 0-9 except (^) the previous random number and then stores the result in t (t::). We initialize t (t:-1;) such that the first result can be any digit 0-9.
The definition of r is purely for convenience in repeatedly invoking it, so you're really only using a single variable.
edit:
Just for fun, here's a k5 program which will generate a sequence of N numbers containing no immediate repetitions (as in the above problem) without using any variables:
1_(*1?10^)\[;-1]

For example,
  1_(*1?10^)\[;-1]10
1 8 0 6 8 5 1 0 5 1
  1_(*1?10^)\[;-1]3
4 0 7

Doesn't work quite right in my K implementation, so I suppose writing this and discovering a bug was a decent use of my time!

Java, 62 bytes
int a(int p){p+=9*(p+Math.random());return p%10==p/10?9:p%10;}

This is a function. You call it with the previously returned value. Uses only the variable supplied.
2 variables, 59 bytes
int a(int p){int a=(int)(Math.random()*9);return a==p?9:a;}

Julia - 25 18 bytes
t=(rand(1:9)+t)%10

Or, for a slightly longer, iterative solution:
while t==(t=rand(0:9))end

No temporary second variable necessary.

Python 2, 79 bytes
Here's a simple one you can repeatedly run in a REPL:
from random import*
try:p
except:p=n=0
while p==n:n=int(random()*9)
print n
p=n

Octave, 24 bytes
Here's an anonymous function using one variable (plus the function handle):
r=@(n)mod(randi(9)+n,10)

Sample run:
>> n=5;
>> n=r(n)
n =  2

Java 8, 89 bytes
As an IntStream...
// Int Stream (89 bytes)
IntStream.iterate(0,(o)->new Random().ints(0,10).filter(x->x!=o).findFirst().getAsInt());

Minimal usage...
// Usage (119 bytes)
IntStream.iterate(0,(o)->new Random().ints(0,10).filter(x->x!=o).findFirst().getAsInt()).forEach(System.out::println);

Javascript, 39 bytes
Not the most exciting answer, but it is in Javascript.
t=-1;while(t==(t=(Math.random()*9)|0));

To test it:

//set the value here, or it will produce repeated numbers:
t=-1;
for(var i=0; i < 10; i++){
    //generate a new random number, using the code in the answer
    while(t==(t=(Math.random()*9)|0));

    document.write(t + '<br>');
}

Python 3, 42 33 bytes
If your criteria for "random" is generating a number 0-9,

[...] without repeating the last generated number.

Something like this would work:
i=(i+1)%10if"i"in globals()else 0

An anonymous user suggested to shorten the code to i=(i+1)%10if"i"in globals()else 0 (which I've rejected as a matter of policy).


text:
What have I got in my pocket?

Synopsis: Find characters that are enclosed by MYPOCKET.

Example Input
MYPHEIF
YFOCKVH
MBNDEIF
TEUFTMY
ESNDUWP
KBOVUVO
CENWFKC
OPYMTEB

Example Output
F
BND
EUF
SNDUW
BOVUV
ENWF

Huh? How did we get that as an output? The "pocket" can sometimes be difficult to see. This will make it clearer:

MYPHEIF
YFOCKVH
MBNDEIF
TEUFTMY
ESNDUWP
KBOVUVO
CENWFKC
OPYMTEB

The letters in bold indicate a ring of characters connected orthogonally to each other consisting of the string MYPOCKET repeated over and over again. Your program should output the characters that are within that ring.
Notes:

There will only be one "pocket".
Trailing new lines or spaces after lines are allowed.
The rest of the grid may also contain characters from MYPOCKET, but not in a way that makes the shape of the ring ambiguous.
The M is not always in the top-right corner.
The "pocket" can move in either a clockwise or a counter-clockwise direction.
The "pocket" won't move in diagonal directions -- that is, each letter is connected left, right, up, or down to the next.

Here's another input you can test your program with.
Example Input
EKCYMOPD
KCOPHAYM
EKNDSEST
JETHACKE
KRMYPOBN

Example Output
  HA
NDSES
 HA

What has it got in its nasty little pocketses?

Was this inspired by this challenge from Anarchy Golf?

@xnor No, it wasn't. (Although it is somewhat similar...)

Perl 5, 414
map{$y=0;push@{$h{$_}},[$-,$y++]for@$_;$-++}@l=map[/./g],<>;sub n{($a,$b,$c,$d)=@_;$a==$c&&1==abs$b-$d||$b==$d&&1==abs$a-$c}sub c{my($x,$y,$n)=@_;for(grep{($f=defined$x)?n$x,$y,@$_:1}@{$h{(MYPOCKET=~/./g)[$n%8]}}){($m,$l)=@$_ if!$f;return@r=([@$_],@r)if$n>2&&n(@$_,$m,$l)||c(@$_,$n+1)}''}c;$l[$_->[0]][$_->[1]]=$" for@r;($l[$_]=join'',@{$l[$_]})=~s/^(\w+)\s|\s(\w+)$/$"x($1||$2)=~y%%%c/eg for 0..@l;print join$/,@l

Usage: save as pocket.pl and run with:
perl pocket.pl <<< '<grid>'

I went for a recursive function to brute-force the path, which might not have been the best, but was the first approach I considered.
Whilst it works for both of the current test cases there are some caveats:

it includes leading spaces (which I didn't see mentioned in the rules...); and
it will definitely not work with a 'pocket' that contains characters in the middle (say U shaped or similar).

I want to continue working on this, but wanted to show that there is interest in the question! Happy to document my process if helpful.

Python 2.7 571 542 509
import sys
o,l,v,k,w="MYPOCKET",[list(e)for e in sys.stdin],[],enumerate,len
def f(z,q,t):
 for r,c in(z,q+1),(z,q-1),(z+1,q),(z-1,q):
  if w(l)>r>=0 and 0<=c<w(l[r])and o[t]==l[r][c]:
    v.append((r,c))
    if f(r,c,(t+1)%w(o)):return 1
    else:v.pop()
 if z==1 and(0,q)in v or z==0 and(z,q+1)in v:return 1
for i,x in k(l[0]):
 v=[(0,i)]
 if x==o[0]and f(0,i,1):break
for i in range(1,w(l)-1):b=[y for x,y in sorted(v)if x==i];print"".join(["".join(e)if w(e)>0 else" "for e in[l[i][b[j-1]+1:y]for j,y in k(b)][1:]])

Works as a program(banking on a recursive function) and accepting input from stdin.
Demo here.Testing it (ex1.txt and ex2.txt are the examples from the question)-
$ python pockets.py < ex1.txt
F
BND
EUF
SNDUW
BOVUV
ENWF
$ python pockets.py < ex2.txt
  HA
NDSES
 HA

Ungolfed version with comments -

s="""
EKCYMOPD
KCOPHAYM
EKNDSEST
JETHACKE
KRMYPOBN
"""
li2=[list(e.strip()) for e in s.split("\n") if e.strip()!='']
buf=[]
def find_precious(row, col, c_ind):
    for r,c in[(row,col+1),(row,col-1),(row+1,col),(row-1,col)]:
        if len(li2)>r>=0 and 0<=c<len(li2[r]) and seq[c_ind]==li2[r][c]:
            if (r,c)in buf:return True
            buf.append((r,c))
            if find_precious(r,c,(c_ind+1)%len(seq)):return True
            else:buf.pop()
    if row==1 and (row-1,col) in buf or row==0 and (row,col+1) in buf:return True
    return False

for i,x in enumerate(li2[0]):
    if x==seq[0]:
        buf=[(0,i)]
        if find_precious(0,i,1):break
if len(buf)==1:
    exit("Failed")

#Calculate the middle men
for i in range(1,len(li2)-1):
    b=[y for x,y in sorted(buf)if x==i]
    print "".join(["".join(e)for e in [li2[i][b[j-1]+1:y]for j,y in enumerate(b)][1:]if len(e)>0])

Let me know, if I did something stupid or something can be done better.
I know it's looong, but it's the best I could do :P

Eh, I'm so bad at Python I'd probably brute-force it //I don't have any knowledge of lambdas in Python...// but nice solution! Still better than none.


text:
Exponentiation of natural numbers using only primitive integer operations
The challenge
Implement the C equivalent of the pow() function (exponentiation) for natural numbers, in a language of your choosing, using only addition, subtraction (which includes negation and comparisons), bit-shifting, boolean operations on signed and/or unsigned integers, and of course looping.
(Note that this is different from hyperexponentiation/tetration, which is repeated exponentiation. This is merely a single application of exponentiation, which can be expressed mathematically as repeated multiplication.)
This is a code-golf challenge, so the shortest answer is king.
Input assumptions
You are computing x raised to the y power. You may assume that x ≥ 1 and y ≥ 1, because 0 is not a natural number. (In other words, you don't have to check for 0⁰.)
Output
Your function should return the correct value for all valid input, except in the event of internal overflow, in which case you may return a garbage value. (In other words, if your language only supports 64-bit integers, then you may return whatever you like for input such as x=10, y=100.)
Bonus
There is a –10 point bonus if your function properly detects internal overflow and either aborts or returns some sort of error condition to the caller.

Is there any time/memory limit? If not, I can just use Cartesian product/power to implement multiplication/exponentiation.

How about string/list multiplication?

I think the more general question is: You list operations that can be used, and operations that cannot be used. What about all other operations? It might be clearer if you have only one list. Either operations that are allowed (with everything else excluded), or operations that are excluded (with everything else allowed).

@RetoKoradi — Thanks — Edited to clarify that.

@Dennis — No time or memory limits... But I edited the details to clarify that it should only use primitive operations, which would exclude Cartesian product/power.

@xnor — Nope, only primitive integer operations.

You mention only functions in your question. Does that mean that full programs are not allowed?

It was a toss-up between voting to close as unclear (because the spec as written prohibits loops, which seems to make it impossible) or as duplicate (because on the assumption that loops are actually intended to be permitted it's just a question of taking the answers to the other question which don't go for the bonus and replacing * with +). The latter seems the more reasonable of the two options, but for future reference when whitelisting operations you should be more careful.

Java, 84
A boring "addition in a double loop" method. One loop is to multiply, the other makes it happen more than once. Works until overflow on int types. The -10 bonus just isn't worth it in Java ;)
int p(int x,int y){int r=1,p,i=0,j;for(;i++<y;r=p)for(p=0,j=0;j++<x;)p+=r;return r;}

CJam, 21 bytes
{1@@,f{;0@@,f{;+}~}~}

Only uses stack manipulation, loops and addition.
Try it online.

Hoo boy! That is fuuuugly code but runs so beautifully! Nice work.

CJam, 22 bytes
Since the other CJam answer uses nested loops, I went with recursion. It's a lot slower.
{:X({:BX(F0\{B+}*}&}:F

Try it online.

Element, 18 bytes
1__'['[2:'+"]#"]#`

This is just a simple double-loop solution. It only uses addition and simple stack operations.  (I'm not done golfing yet).
Input is like
5
3

for 5^3 giving 125.
Here's a very similar 18 byte solution:
1_'_'["#[2:'+"]']`

Pyth, 27 bytes
K1Vr0@Q1J0Vr0@Q0=J+JK)=KJ)K

Works by adding numbers together whilst looping. Takes input in the form:
x,y

Try it here.

Haskell, 37 bytes
(foldl1((sum.).replicate).).replicate

Usage example (note: exponent comes first, then base):
Prelude> ((foldl1((sum.).replicate).).replicate) 5 2
32

Prelude> ((foldl1((sum.).replicate).).replicate) 6 3
729

Python 2, 67 62 bytes
m=lambda x,y:y and x+m(x,y-1);p=lambda x,y:y<1or m(x,p(x,y-1))

This is an obvious solution: define multiplication in terms of addition, then exponentiation in terms of multiplication.
Unfortunately, this rather naive implementation very quickly reaches the maximum recursion depth (Python's default maximum depth is 1000, I think).  For instance, you can do p(9, 4) and it immediately outputs 6561. But if you try p(10, 4) it chokes, because it ultimately has to evaluate m(10, 1000) (that is, 10*1000) and it takes 1000 nested additions to do it.
Of course, you can always raise the stack depth limit...
By the way, p(0, 0) returns 1, which is desirable behavior in my view (if interested, please see my answer and comment here: https://math.stackexchange.com/questions/20969/prove-0-1-from-first-principles/1094926#1094926).
Thanks so much to xnor for saving me 5 bytes!

Nice job getting an answer in in the same minute the question is closed.

@ThomasKwa Uh, thanks. This is a little like handing in your test as the professor is walking out the door.

It's a bit shorter to do 0**y or _ for _ if y else 1.

@xnor I don't think I'm allowed to use built-in exponentiation 0**y in this challenge?

@mathmandan Ah, right, that's funny. y<1or should work instead and is shorter.

@xnor Great, thanks so much for your help!  I have incorporated your very nice improvement.

 Powershell - 124 bytes
:\>cat pow.ps1

filter m([double]$a,$b){$r=0;while($b--){$r+=$a};return $r}
filter p([double]$c,$d){$s=1;while($d--){$s=m $s $c};return $s}

:\>cat pow.ps1 | wc --chars
124

:\>runpow.bat

:\>powershell -nologo -noexit -c "& {. .\pow.ps1; p 3 4;p 2 10; p 10000 77; p 10000 78}"

81
1024
1.0000000000004E+308
Infinity  <------- if result above [double]::MaxValue

PowerShell 51 bytes
(answer prior to edit concats a multipliable string and evaluates it )
$p=[string]$args[0]+"*";powershell($p*$args[1]+"1")

result
PS E:\> .\pow.ps1 10076.45 77
1.79755288402548E+308
PS E:\> .\pow.ps1 2 10
1024
PS E:\> .\pow.ps1 10 100
1E+100
PS E:\> .\pow.ps1 4 20
1099511627776
PS E:\> .\pow.ps1 20 4
160000
PS E:\> .\pow.ps1 10077 77
Infinity

Is this using only primitive integer operations?

(I didn't downvote you, by the way.)

@ToddLehman No, this uses multiplication :/