text:
Two Symbol Math
Introduction
The four basic math operators (+, -, *, /) can be reduced to just two, due to the fact that:
x + y = x - (-y)
x * y = x / (1/y), y != 0
x * 0 = 0/x

Challenge
The challenge is to take input as a "string" containing:

Numbers
Single character variables ("x", "y")
The four basic math operators (+, -, *, /)
Parenthesis

and output a string manipulated so that it would produce the same mathematical result as the input, but containing only the mathematical symbols '-' and '/'
Specifics

Input can be in any acceptable form (file, STDIN, etc.) and may be represented as a string or character array (but not an array of arrays)
Output can be in any acceptable form (file, STDIN, etc.) and may be represented as a string or character array (but not an array of arrays)
You must recognize and maintain balanced parenthesis
Standard loopholes are disallowed
It is your choice if you want to represent x + y as x - -y or x - (-y)
You must maintain the order of operations
You never have to handle invalid input
Input can be empty or a single number/variable, in that case the program should output the input
Note: You do not have to use the substitutions in the introduction, so long as input = output, your program could change 2 * 2 to 8/2, if you wanted
You can assume that "0" is the only way a zero will appear in the equation (I.e. you don't have to handle 1 * (4 - 4))
Suggestion: to test your program, go to this website type in input = output, where input is the input, and output is the output, and if the result is "true" your program handled that case successfully (example, example)

Test Cases
Below are some test cases, input as a single string and output as a single string.
x + y
x - (-y)

x * y
x / (1/y)

x / y
x / y

x - y
x - y

1
1

5
5

-6
-6

+x
x

1 + (x * 4) - (512 * 3)
1 - (-(x / (1/4))) - (512 / (1/3))

1 - 3 / 4 + l / g
1 - 3/4 - (-(l / g))

5 * 0 / 2
0/5 / 2

(a + g) * 0
0/(a - (-g))

Scoring
It's code-golf, so shortest answer in bytes wins. Ties are resolved by first-post.

By the way x / 1/y = x/y because division isn't associative. I know what you're thinking, but even WolframAlpha doesn't recognize that you want spaces to change the order of operations.... so you probably should rethink this or not cite that as a valid way to check things.

@Linus: It also isn't equivalent when y=0, but I'm guessing the challenge implicitly assumes that n/d => d != 0.

@TimČas ahh! Didn't think of that. I'll update the challenge, just know it will have to be handled properly

As it stands, there's very little stopping us from simply evaluating the expression and returning the result (they're mathematically equal, after all).  I'd recommend changing that, unless you want v to be a proper solution in Pyth.

Wait, so if there are variables (like x and y), how can we divide without risking division by zero? 5 * (a - b) if a=b. And do we have to detect things like 5 * (a - a)? How about 5 * (4 - 4) and 5 * (a / a - 1) or 5 * (4 / 4 - 1)?

@Adam you only have to handle "0" itself, I'll update the challenge

Can we assume that there will be no spaces in the input or do we have to strip them?

@BetaDecay handle them... But they're not required in output.

Python 3, 267 bytes
Thanks to @ConorO'Brien
import re
q=re.sub
g=lambda m:'--'+m.group()[1:]
h=lambda m:'/(1/'+m.group()[1:]+')'
i=lambda m:'0/'+m.group()[:-2]
print(q(r'\*[^\(\)]+',h,q(r'[^\(\)]\*0',i,q(r'\+[^\(\)]+',g,q(r'\*\([^\)]+\)',h,q(r'\([^\)]+\)\*0',i,q(r'\+\([^\)]+\)',g,input().replace(' ',''))))))))

Ideone it!

Honestly, I've no idea what dark magic you've employed, but +1 for FGITW

@SocraticPhoenix Haha the dark magic is called regex ;)

Dyalog APL, 42 bytes
This maintains APLs order of operations. Note that ÷x is 1÷x
'\+' '×'⎕R'--' '÷÷'('(.*)×0'⎕R'0÷\1'~∘' ')

TryAPL online!
( on the result of...
 ~∘' ' remove spaces
 '(.*)×0'⎕R'0÷\1' replace anything followed by "×0" with "0÷" followed by it
) evaluate...
'\+' '×'⎕R'--' '÷÷' replace "+" with "--" and "×" with "÷÷"
To verify:

Assign random non-zero numbers to x, y, l, g, and a.

Execute the original expressions.

Execute the modified expressions.

Compare the results.

SED 272 246 239 213
s,^\+,,;s,[^+*/()-]\+,(&),g;t;:;s,)[^)]*)\*(0,&,;tr;s,\((.*)\)\*(0),(0/\1),;ty;s,\*([^)]*(,&,;tr;s,\*\(([^)]*)\),/(1/\1),;ty;s,\+([^)]*(,&,;tr;s,\+\(([^)]*)\),-(-\1),;ty;p;q;:r;s,(\([^()]*\)),!\1@,;t;:y;y,!@,(),;b

Take input without spaces (e.g. x+y*2).
This is one of the few cases where it is actually shorter to just escape ( and ) for capture groups instead of using -r. I'm sure this can be golfed more, but I'm happy for now.
Ungolfed, with comments:
s,^\+,, #remove leading +
s,[^+*/()-]\+,(&),g #suround numbers/variables in ()
t start #reset the test because the line above will always match

:start
#------------- deal with *0 ------------------
s,)[^)]*)\*(0,&, #remove inner matching ()
t replace
s,\((.*)\)\*(0),(0/\1),
t y
#------------- deal with generic * -----------
s,\*([^)]*(,&, #remove inner matching ()
t replace
s,\*\(([^)]*)\),/(1/\1),
t y
#------------- deal with + -------------------
s,\+([^)]*(,&, #remove inner matching ()
t replace
s,\+\(([^)]*)\),-(-\1),
t y

b end #all done, branch to the end

#------------- replace a set of () with !@ ---
#repeated application of this helps find the matching ( or )
:replace
s,(\([^()]*\)),!\1@,
t start

:y
y,!@,(),
b start

:end


text:
Build a sandpile
An abelian sandpile, for our purposes, is an infinite grid with integer coordinates, initially empty of sand. After each second, a grain of sand is placed at (0,0). Whenever a grid cell has 4 or more grains of sand, it spills one grain of sand to each of its four neighbors simultaneously. The neighbors of (x,y) are (x-1,y), (x+1,y), (x,y-1), and (x,y+1).
When a cell spills, it may cause its neighbors to spill. Some facts:

This cascade will eventually stop.
The order in which the cells spill is irrelevant; the result will be the same.

Example
After 3 seconds, the grid looks like
.....
.....
..3..
.....
.....

After 4 seconds:
.....
..1..
.1.1.
..1..
.....

After 15 seconds:
.....
..3..
.333.
..3..
.....

And after 16 seconds:
..1..
.212.
11.11
.212.
..1..

The challenge
In as few bytes as possible, write a function that takes a single positive
integer t and outputs a picture of the sandpile after t seconds.
Input
A single positive integer t, in any format you choose.
Output
A picture of the sandpile after t seconds, using the characters
 . 1 2 3

Edit: Use any four distinct characters you like, or draw a picture. If you're not using ".123" or "0123", specify in your answer what the characters signify.
Unlike in the examples, your output should contain the minimal number of rows and columns necessary to show the nonzero part of the sandpile.
That is, for input 3, the output should be
 3

For 4, the output should be
 .1.
 1.1
 .1.

Scoring
Standard golf scoring applies.
Rules
No language functions or libraries that already know what a sandpile is are allowed.
Edit: The output section has been edited, the character set restriction has been completely lifted. Use any four distinct characters or colors you like.

Can the input t be 0? What's the ouput then?

Is it correct for at a given timestep multiple cascades can take place in a row? So in that timestep the cascades keep happening until every cell is again 3 or less?

@flawr: Yes, that would be correct. Look at the difference between t=15 and t=16.

@LuisMendo The input is specified as positive t, so zero isn't a valid input.

Is it REALLY that necessary to have . for empty cells? Can we have 0 as a valid empty cell?

@AndreïKostyrka I guess it's not necessary. I'll update the spec.

Also, is it really that necessary to output a n×n text area? Can matrices or arrays be outputted instead? I mean, normally, in such challenges, it is the result that matters, not the fancyness of the output. Arrays and matrices are so common, there is no need to reformat them as square text blocks, unless the formatting trick is a part of the challenge.

@EricTressler Thank you!

@EricTressler Since you have relaxed the output format, you should notify other answers so that they can maybe shorten their code (I already have)

R, 378 343 297 291 bytes
As usually, the user supplies his/her input via scan() (I already used the variable t, so let us take z instead), so the second line should be launched separately, and then the rest:
e=numeric
a=1%*%scan()
x=1
o=a>3
n=1
while(any(o)){
v=which(o,T)
if(any(v==1)){a=rbind(e(n+2),cbind(e(n),a,e(n)),e(n+2));x=x+1;n=n+2;v=which(a>3,T)}
q=nrow(v)
u=cbind(e(q),1)
l=v-u[,1:2];r=v+u[,1:2];t=v-u[,2:1];b=v+u[,2:1]
a[l]=a[l]+1;a[r]=a[r]+1;a[t]=a[t]+1;a[b]=a[b]+1
a[v]=a[v]-4
o=a>3}
a

Outputs an array that contains the values of a at tth generation (0, 1, 2 or 3).
Test cases:
z=3
     [,1]
[1,]    3
z=4
     [,1] [,2] [,3]
[1,]    0    1    0
[2,]    1    0    1
[3,]    0    1    0
z=16
     [,1] [,2] [,3] [,4] [,5]
[1,]    0    0    1    0    0
[2,]    0    2    1    2    0
[3,]    1    1    0    1    1
[4,]    0    2    1    2    0
[5,]    0    0    1    0    0

It helps us that this thing is symmetrical both vertcially and horizontally, which means that is the leftmost point gets a height of 4, this means that the topmost, rightmost and lowest points are also 4.
Oh, and did I say that you can make beautiful visualisations?
After 1000 drops:

After 50000 drops (≈4 seconds):

After 333333 drops (≈15 minutes):

You can draw it, too!
image(1:n,1:n,a,col=colorRampPalette(c("#FFFFFF","#000000"))(4), axes=F, xlab="", ylab="")

This thing took 4 seconds for 10000 iterations but slows down considerably for larger array sizes (e.g. a couple of minutes for 100000 iterations). This is why it gets so slow (I estimated the growth rate as in  and obtained  τ(i)≈689·i^1.08, so the average time per one additional grain until the whole sandpile settles after ith step is slightly larger than one), and the total time as a function of the number of grains grows a little bit slower than quadratically (T(i)≈0.028*i^1.74):

And now with a complete explanation:
e=numeric # Convenient abbreviation for further repeated use
a=1%*%scan() # Creates a 1×1 array with a user-supplied number
x=1 # The coordinate of the centre
o=a>3 # Remember which cells were overflown
n=1 # Array height that is going to change over time
while(any(o)){ # If there is still any overflow
  v=which(o,T) # Get overflown cells' indices
  if(any(v==1)){ # If overflow occurred at the border, grow the array
    a=rbind(e(n+2),cbind(e(n),a,e(n)),e(n+2)) # Growing
    x=x+1 # Move the centre
    n=n+2 # Change the height
    v=which(a>3,T) # Re-index the overflowed cells
    }
  q=nrow(v) # See how many indices are overflown
  u=cbind(e(q),1) # Building block for neighbours' indices
  l=v-u[,1:2];r=v+u[,1:2];t=v-u[,2:1];b=v+u[,2:1] # L, R, T, B neighbours
  a[l]=a[l]+1;a[r]=a[r]+1;a[t]=a[t]+1;a[b]=a[b]+1 # Increment neighbours
  a[v]=a[v]-4 # Remove 4 grains from the overflown indices
  o=a>3} # See if still overflown indices remain
a # Output the matrix

This is the first time in my life when growing objects (like a <- c(a, 1)) works so much faster than pre-allocating a big empty matrix for values and filling it gradually with a ton of zeros unused.
Update. Golfed 18 bytes by removing arr.ind in which owing to Billywob and replacing rep(0,n) with e=numeric;e(n) in 5 instances owing to JDL, and 17 more bytes owing to JDL.
Update 2. Since the sandpile is Abelian, it may start with a stack of desired height, so I removed the redundant loop and gained a huge boost in productivity!

I get your point about the extra column,row indices that you're outputting, but I think I want to restrict the output to just being "the answer", and nothing more. I'm glad you included pictures, though.

@EricTressler Those are outputted by default; it is just a reference. If you have a look just at the a array, it is a perfectly parsimonious array with no extra indices in the headers; it is a n×n object. I ran it for some time and provided extra evidence why my coding is quadratically inefficient!

Nice answer Andreï! You could definitely golf a few bytes though, for instance predefining rep(), given that you use it 6 times. Secondly, I don't think you need to write out the arr.ind=T option for the which() function. Simply use which(...,T).

It may be golfier to define n=numeric and use that instead, since n(k) is fewer characters than r(0,k). I like the pictures though.

@Billywob Thank you, this has been done.

@JDL Same goes for your suggestion: implemented, thank you!

Another suggestion: 1%*%0 is fewer characters than array(0,c(1,1)). Also the second argument to u <- cbind can just be 1, cbind will extend it to the length of the first argument by default.

@JDL If R had a compiler, it would have thrown a warning after what you’ve suggested, ha-ha, but it works!

Please note that users don't have to be male.

@GregMartin When did I say something wrong?..

"the user supplies his input"

@GregMartin Fixed this. Sorry for that; in my first language, we use the word “self’s” and never bother about the gender of the person in question (like “one small step for a man”); still, sometimes, at very rare occasions, I call a dog “she” or a “he”, whereas it should be “it”, unless, like, you are the owner and you really want to emphasize the sex of your anumal (in spite of the fact that telling a male from a female is not that hard).

Fair enough, I figured it could be a first/second/third language issue. Still important though, so thank you for the change!

MATL, 55 53 48 43 42 bytes
Inspired by @flawr's answer.
Graphical output:
0i:"Gto~+XytP*+t"t4=t1Y6Z+b+w~*]]tat3$)1YG

Try it at MATL Online!. It takes about 10 seconds for input 30. You may need to refresh the page and press "Run" again if it doesn't work.
Here's an example result for input 100:

ASCII output (43 bytes):
0i:"Gto~+XytP*+t"t4=t1Y6Z+b+w~*]]tat3$)48+c

Try it online!
Explanation
0          % Push a 0. This is the initial array. Will be resized in first iteration
i:         % Take input n. Generate range [1 2 ... n]
"          % For each, i.e. repeat n times
  Gto~+    %   Push input and add negate parity. This "rounds up" n to odd number
           %   m = n or n+1
  Xy       %   Identity matrix with that size
  tP*      %   Multiply element-wise by vertically flipped copy. This produces a
           %   matrix with a 1 in the center and the rest entries equal to 0
  +        %   Add to previous array. This updates the sandpile array
  t        %   Duplicate
  "        %   For each column (i.e. repeat m times)
    t4=    %     Duplicate. Compare with 4 element-wise. This gives a 2D mask that
           %     contains 1 for entries of the sandpile array that equal 4, and 0
           %     for the rest
    t      %     Duplicate
    1Y6    %     Predefined literal: [0 1 0; 1 0 1; 0 1 0]
    Z+     %     2D convolution, maintaining size
    b      %     Bubble up to bring sandpile array to top
    +      %     Element-wise addition. This adds 1 to the neighbours of a 4
    w      %     Swap to bring copy of mask to top
    ~*     %     Multiply bu negated mask. This removes all previous 4
  ]        %  End
]          % End
t          % Duplicate the updated sandpile array
a          % 1D mask that contains 1 for columns that contain a 1. This will be
           % used as a logical index to select columns
t          % Duplicate. This will be used as logical index to select rows (this
           % can be done because of symmetry)
3$)        % Keep only those rows and columns. This trims the outer zeros in the
           % sandpile array
1YG        % Display as scaled image

I'm jealous of 1Y6.

@flawr But your ~mod(spiral(3),2) is much more clever :-)

Matlab, 160 156 148 bytes
n=input('');z=zeros(3*n);z(n+1,n+1)=n;for k=1:n;x=z>3;z=z+conv2(+x,1-mod(spiral(3),2),'s');z(x)=z(x)-4;end;v=find(sum(z));z=z(v,v);[z+48-(z<1)*2,'']

First a way too big matrix is created, with the n in the middle somewhere. Then the cascading is calculated with a very convenient 2d convolution. At the end the excess is trimmed off and the whole thing is converted to a string.
Example output for t=100
...121...
..32.23..
.3.323.3.
123.3.321
2.23.32.2
123.3.321
.3.323.3.
..32.23..
...121...

As always:

Convolution is the key to success.

v=any(z) instead of v=find(sum(z)) (I'm using that in my answer). Also, 2*~z instead of (z<1)*2

My computer froze on input n=500... It had been processing n=400 for several seconds. Am I doing something wrong?

@AndreïKostyrka It works for me (Matlab R2015b)

@AndreïKostyrka For an input of n this program generates an 3*n x 3*n matrix, so it needs to store about 9*n^2 numbers. Also it is totally inefficient, because we also have a totally unnecessary long iteration from 1 upto n. But then again this is [tag:code-golf], making a program efficient is a different cup of tea.

@AndreïKostyrka You can makie it more memory efficient by using sparse matrices (second line: z=sparse(zeros(2*n+1))) and changing the for loop to while any(z(:)>3). Then you can also perhaps compute the convolution kernel just once: kern = 1-mod(spiral(3),2).

Python 2, 195 +1 +24 = 220 217
from pylab import*
ifrom scipy.signal import convolve2d as c
k=(arange(9)%2).reshape(3,3)
def f(n):g=zeros((n,n),int);g[n/2,n/2]=n;exec"g=c(g/4,k,'same')+g%4;"*n;return g[any(g,0)].T[any(g,0)]

output for n=16
array([[0, 0, 1, 0, 0],
       [0, 2, 1, 2, 0],
       [1, 1, 0, 1, 1],
       [0, 2, 1, 2, 0],
       [0, 0, 1, 0, 0]])

there is a LOT of unnecessary padding and iterations, by using n as a "good-enough" upper bound, but n=200 still completed in a second and n=500 in about 12 seconds
ungolfed
from pylab import*
from scipy.signal import convolve2d as c
k=array([0,1,0],
        [1,0,1],
        [0,1,0])
def f(n):
  g=zeros((n,n))                 # big grid of zeros, way bigger than necessary
  g[n/2,n/2]=n                   # put n grains in the middle
  exec"g=c(g/4,k,'same')+g%4;"*n # leave places with <4 grains as is, convolve the rest with the kernel k, repeat until convergence (and then some more)
  return g[any(g,0)].T[any(g,0)] # removes surrounding 0-rows and columns

replacing return x by imshow(x) adds one character and outputs an ugly interpolated image, adding imshow(x,'gray',None,1,'nearest') removes the blurry interpolation bringing the output up to specs

I get the following error when I run your code: ImportError: No module named convolve2d. Changing import scipy.signal.convolve2d as c to from scipy.signal import convolve2d as c resolves the issue. I am using scipy version 0.16.1, do I need an older or newer version? Or is the issue something else?

weird, now that you mention that it doesnt work for me anymore either. I probably did it right the first time in interactive mode, then shortened it and ignored the error, but the function stayed in memory

Perl, 157 147 bytes
Includes +1 for -p
Run with the count on STDIN, prints the map using 0123 to STDOUT:
sandpile.pl <<< 16

sandpile.pl:
#!/usr/bin/perl -p
map{++substr$_,y///c/2-1,1;/4
/?$.+=s%^|\z%0 x$..$/%eg+!s/\b/0/g:s^.^$&%4+grep{3<substr$\,0|$_+"@+",1}-$.-2,-2,0,$.^eg while/[4-7]/}($\="0
")x$_}{

Python 3 2, 418 385 362 342 330 bytes
w='[(i,j)for i in r(n)for j in r(n)if a[i][j]>3]'
def f(z):
 a,x,r=[[z]],0,range
 for _ in[0]*z:
  n=len(a);v=eval(w)
  if[1for b,c in v if(b==0)+(c==0)]:n+=2;a=[[0]*n]+[[0]+a[i]+[0]for i in r(n-2)]+[[0]*n];x+=1;v=eval(w)
  for c,d in v:exec'a[c+%s][d+%s]+=1;'*4%(-1,0,1,0,0,-1,0,1);a[c][d]-=4
 for i in a:print''.join(map(str,i))

Edit: saved 6 bytes thanks to @Qwerp-Derp
All credit to @Andreï Kostyrka, as this is a direct translation of his R code into Python.

I think you can move the assignment of a,x,r into the function arguments.

I've golfed down your code by a few bytes... it's not much, but it'll have to do. Do you mind if I put an edit on your answer and if I change the version of Python to Python 2?

@Qwerp-Derp: Feel free! I'd love to see what you've done.

JavaScript, 418 416 406 400 393 bytes
Creates an anonymous function that displays the output on the console.

var f =
    t=>{a=(q,w)=>Math.max(q,w);c=_=>{x=a(p[0],x);y=a(p[1],y);m[p]=(g(p)+1)%4;if(!m[p]){s.push([p[0],p[1]]);}};x=y=0,m={};g=k=>{v=m[k];return!v?0:v;};m[o=[0,0]]=1;s=[];while(--t){m[o]=(m[o]+1)%4;if(!m[o]){s.push(o);}while(s.length){p=s.pop();p[0]++;c();p[0]-=2;c();p[0]++;p[1]++;c();p[1]-=2;c();p[1]++;}}s='';for(i=-x;i<=x;i++){for(j=-y;j<=y;j++){v=g([i,j]);s+=v==0?'.':v;}s+='\n';}console.log(s);}
<input id="i" type="number"><input type="button" value="Run" onclick="var v = +document.getElementById('i').value; if (v>0) f(v)">

Warning: I pressed 'run' without input, and my screen crashed (infinite loop). Don't be as silly as I was.

@Roberrrt I updated my answer to prevent this.

Scala, 274 bytes
val t=args(0).toInt
val s=(Math.sqrt(t)+1).toInt
val (a,c)=(Array.ofDim[Int](s,s),s/2)
(1 to t).map{_=> ?(c,c)}
println(a.map{_.mkString}.mkString("\n"))
def?(b:Int,c:Int):Unit={
a(b)(c)+=1
if(a(b)(c)<4)return
a(b)(c)=0
?(b+1,c)
?(b-1,c)
?(b,c+1)
?(b,c-1)
}

Usage:
scala sandpile.scala <iterations>
I don't think there is a lot to explain about this one. Basically it just adds one grain of sand to the center. Then checks if it is larger than 4, if so it'll spill over and check for all neighbours larger than 4, spill over, etc. It's quite fast.
Performance:

t=10000  72ms
t=20000  167ms
t=30000  419ms
t=40000  659ms
t=100000 3413ms
t=1000000 about 6 minutes

My program suggests that, centered at (0,0), the sandpile first hits a radius of 15 at t=1552. That would require a 31x31 array to store (coordinates -15 to 15 inclusive). Are you sure this is correct through t=5000?

I am not sure this is correct, though I think I got the logic right? I get an array index out of bounds exception on t>5593

When I increment and then immediately check for spillage it does go out of bounds at t=1552. I'd say that is the correct implementation. I updated the code.

Your performance can be beaten only by direct array manipulation in C or Fortran with compiler optimisation. I envy you.

@AndreïKostyrka, yes, this is where scala shines! My output doesn't conform to the specs though so I'd have to work on that

Since the sandpile is Abelian and the order of addition/spill-overs does not matter, you might want to compare the performance of incremental method (add grain — let the pile settle — add grain — let the pile settle ...) versus the initial construction of a tower of height T and letting it fall down and fill the allocated space with the same final result.

@AmazingDreams Owing to the fact that it can be proven that two adjacent cells will never be empty, in the worst theoretical case the area of the half-filled checkerboard-pattern circle (containing the maximum area) T corresponds to the circle diameter of 2*sqrt(2T/π): 2T is the number of points doubled for the worst case (least dense packing with no adjacent empty cells, i. e. a checkerboard), which is the area of a circle, so we divide by π and take the square root to get the radius, and multiply by two for the diameter. You should never need an array larger than the ceiling of that number.

@AmazingDreams How did you get your performance metrics? I ran your code locally and got much slower results. That said, I also just downloaded scala to run your example, so running it based off of your usage may not be the fastest approach. ;)

@DannyKirchmeier Add val start=System.currentTimeMillis to the top and println(System.currentTimeMillis - start +"ms") to the bottom. You have to keep in mind that scala runs on the JVM which has some warmup time which shouldn't be considered part of the performance of the algorithm, so you cannot just measure from command start to command end. Furthermore it obviously depends a lot on your CPU speed, on this computer with around 2.8Ghz I get 3881ms for T=100000. I'll have to check the speed of the other computer.

@AndreïKostyrka, I tried what you suggested about building a tower of height T, it doesn't help much though.

@AmazingDreams Ah, that explains it. Also, I found in my nim solution that sqrt(t)+1 gave me a large enough grid, so you can trim out some of the bytes taken up by your s calculation.

@DannyKirchmeier thanks for that tip! What speed do you get?

@AmazingDreams I have a 2GHz i7 mac pro. I updated my answer with performance metrics too. The smaller inputs run faster than your scala version, but get much slower for larger inputs. Nim compiles down to c and runs from there, which at least explains why my start time is so much smaller than yours.

@DannyKirchmeier, I bet nim/c would run faster than scala if I ran it here on this 3.5GHz beast. I noticed I made an error for the 1.000.000 input, it runs in about 6 minutes. A minute faster than your solution.

Let us continue this discussion in chat.

Nim, 294 characters
import os,math,sequtils,strutils
var
 z=parseFloat paramStr 1
 y=z.sqrt.toInt+1
 w=y/%2
 b=y.newSeqWith newSeq[int] y
 x=0
proc d(r,c:int)=
 b[r][c]+=1;if b[r][c]>3:b[r][c]=0;d r-1,c;d r,c+1;d r+1,c;d r,c-1
for i in 1..z.toInt:d w,w
while b[w][x]<1:x+=1
for r in b[x..< ^x]:echo join r[x..< ^x]

Compile and Run:
nim c -r sandbox.nim 1000

Notes:

I was able to come up with a shorter version which uses a fixed table size, but I edited it out in favor of the dynamic one.
Once the sandbox is computed, x is calculated as the number of zero columns at the start of the middle row.
For display, the table is sliced down by excluding x rows and columns from each end.

Performance
nim c --stackTrace:off --lineTrace:off --threads:off \
      --checks:off --opt:speed sandbox.nim

time ./sandbox   10000       0.053s
time ./sandbox   20000       0.172s
time ./sandbox   30000       0.392s
time ./sandbox   40000       0.670s
time ./sandbox  100000       4.421s
time ./sandbox 1000000    6m59.047s

J, 76 bytes
p=:0,.~0,.0,~0,]
p`(4&|+3 3([:+/@,*&(_3]\2|i.9));._3[:<.4%~p)@.([:*/4>{.)^:_

I define a verb p which pads a border of zeros around the input. The main verb takes an array as input. It then checks the first row for any sandpile that contains 4 or more grains. If one does, it outputs the same array except padded using p, and otherwise it performs 2d convolution to simulate falling grains. The main verb is repeated until convergence using the power operator ^:_.
Usage
   p =: 0,.~0,.0,~0,]
   f =: p`(4&|+3 3([:+/@,*&(_3]\2|i.9));._3[:<.4%~p)@.([:*/4>{.)^:_
   f 15
0 3 0
3 3 3
0 3 0
   f 50
0 0 0 1 0 0 0
0 0 3 1 3 0 0
0 3 2 2 2 3 0
1 1 2 2 2 1 1
0 3 2 2 2 3 0
0 0 3 1 3 0 0
0 0 0 1 0 0 0
   timex 'r =: f 50000'
46.3472
   load 'viewmat'
   ((256#.3&#)"0<.255*4%~i._4) viewmat r

It takes about 46 seconds to compute the result for n = 50000, and the result can be displayed using the viewmat addon with a monochrome color scheme.

C 222
Thanks to @ceilingcat for some very nice pieces of golfing - now even shorter
G[99][99],x,y,a,b,c,d;S(x,y){++G[y][x]>3?G[y][x]=0,S(x+1,y),S(x-1,y),S(x,y+1),S(x,y-1):0;a=x<a?x:a;b=y<b?y:b;c=x>c?x:c;d=y>d?y:d;}F(t){for(a=b=99;t--;)S(49,49);for(y=b;d/y;y+=puts(""))for(x=a;c/x;)printf("%d ",G[y][x++]);}

Try it online!

Okay, I give up: why is your array 99 by 98?

@EricTressler How did I not find that in testing?!

APL (Dyalog Unicode), 51 bytesSBCS
{m⌿r/⍨m←⌈/×r←(4∘|+{+/⊢/4 2⍴⌊⍵÷4}⌺3 3)0,∘⍉∘⌽⍣4⊢⍵}⍣≡⍪

Try it online!

PHP, 213 bytes
function d($x,$y){global$p,$m;$m=max($m,$x);$q=&$p[$y][$x];if(++$q>3){$q=0;d($x+1,$y);d($x-1,$y);d($x,$y+1);d($x,$y-1);}}while($argv[1]--)d(0,0);for($y=-$m-1;$y++<$m;print"\n")for($x=-$m;$x<=$m;)echo+$p[$y][$x++];

recursively creates the pile in $p, remembering the size in $m; then prints with nested loops.
Run with -r.

source: Stack Exchange

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

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

sort: votes


text:
Chuck Norris vs Travelling Salesman
Introduction
Almost everyone is familiar with the Travelling Salesman Problem (TSP). The task is to, given a list of N cities, find the minimum Hamiltonian cycle which is to say the shortest path that visits each city and comes full-circle back to the start. That is not what this challenge is about. This challenge is to implement Chuck Norris' solution to the TSP:

Chuck Norris solved the Travelling Salesman problem in O(1) time: break salesman into N pieces; kick each piece to a different city.

Challenge
In order to solve the TSP in this way, we need a sufficiently durable Salesman that won't shy away from frivolities like dismemberment; a number of cities to visit; a set of products to sell; a concrete method for dismemberment; and a calculation for scoring.
Specification

Cities

N is the number of cites our Salesman will visit

Salesman

The main program or function
Written in language X
With length mod N equal to 0

Products

The full names of the elements on the Periodic Table
This includes the newly accepted names of elements

Dismemberment

Slicing the Salesman into N continuous pieces of equal length
Each piece is should be a valid function or program in language X

Output

When executed the Salesman should output Chuck Norris and the sliced pieces should each output a distinct product
Only extra trailing white space is acceptable

Scoring

The length, L, of the Salesman in bytes divided by the number of cities, N, squared.
Score = L/(N*N)
Smallest score wins
Please include 3 significant figures when posting your decimal score

Examples

This Salesman visits 3 cities so N=3 and and it has a length of 9 so L=9. Thus the score for this answer would be S = 9 / (3 * 3) = 9/9 = 1.

Note that the Salesman and each sliced piece (of which there are 3), should all be valid programs or functions in the same language.

Program      -> Output
-------         ------
aaaBBBccc    -> Chuck Norris

aaa          -> Helium
BBB          -> Iridium
ccc          -> Tennessine

N=4 and L=20 so S=20/16=1.25

Program                 -> Output
-------                    ------
aaaaaBBBBBcccccDDDDD    -> Chuck Norris

aaaaa                   -> Hydrogen
BBBBB                   -> Cadmium
ccccc                   -> Mercury
DDDDD                   -> Iron

Are built-ins like Mathematica's ElementData allowed? (I doubt it'll save much, but I don't know.)

Is capitalisation of the outputs important?

@MartinEnder ^^ yes ^ yes

Could any of the close voters explain which part they actually find unclear? (I know it can't be just my two questions, which I don't even think need to be explicitly addressed in the challenge, because there were already close votes when I posted them.)

Totally agree with @MartinEnder. If you don't like a challenge, just try another one.

Isn't "break salesman into N pieces; kick each piece to a different city." O(N)? One break and kick per city? Obviously, it's still O(1) for Chuck Norris and Jon Skeet (everything is O(1) for Jon Skeet), but in my experience anyone else dismembering and distributing salesmen will find themselves working longer for more cities.

CJam, L = 1482, N = 114, score 0.114
'C:L"arbon"  L'h+:L;"Gold"L'u+:L;"Iron"L'c+:L;"Lead"L'k+:L;"Neon"LS+:L;"Argon"L'N+:L"ickel"L'o+:L;"Zinc""Coppe"L'r+:L"Silve"L'r+:LL'i+:L;"Tin" "Boron"      "Radon"      "Barium"     "Cerium"     "Cesium"     "Cobalt"     "Curium"     "Erbium"     "Helium"     "Indium"     "Iodine"     "Osmium"     "Oxygen"     "Radium"     "Sodium"     "Sulfur"     "Arsenic"    "Bismuth"    "Bohrium"    "Bromine"    "Cadmium"    "Calcium"    "Dubnium"    "Fermium"    "Gallium"    "Hafnium"    "Hassium"    "Holmium"    "Iridium"    "Krypton"    "Lithium"    "Mercury"    "Niobium"    "Rhenium"    "Rhodium"    "Silicon"    "Terbium"    "Thorium"    "Thulium"    "Uranium"    "Yttrium"    "Actinium"   "Aluminum"   "Antimony"   "Astatine"   "Chlorine"   "Chromium"   "Europium"   "Fluorine"   "Francium"   "Hydrogen"   "Lutetium"   "Nihonium"   "Nitrogen"   "Nobelium"   "Platinum"   "Polonium"   "Rubidium"   "Samarium"   "Scandium"   "Selenium"   "Tantalum"   "Thallium"   "Titanium"   "Tungsten"   "Vanadium"   "Americium"  "Berkelium"  "Beryllium"  "Flerovium"  "Germanium"  "Lanthanum"  "Magnesium"  "Manganese"  "Moscovium"  "Neodymium"  "Neptunium"  "Oganesson"  "Palladium"  "Plutonium"  "Potassium"  "Ruthenium"  "Strontium"  "Tellurium"  "Ytterbium"  "Zirconium"  "Dysprosium" "Gadolinium" "Lawrencium" "Meitnerium" "Molybdenum" "Phosphorus" "Promethium" "Seaborgium" "Technetium" "Tennessine" "Californium""Copernicium""Einsteinium""Livermorium""Mendelevium""Roentgenium"]L's+"Xenon"?

Try it online!
Each program is 13 bytes long. Here they are split up into individual lines:
'C:L"arbon"
L'h+:L;"Gold"
L'u+:L;"Iron"
L'c+:L;"Lead"
L'k+:L;"Neon"
LS+:L;"Argon"
L'N+:L"ickel"
L'o+:L;"Zinc"
"Coppe"L'r+:L
"Silve"L'r+:L
L'i+:L;"Tin"
"Boron"
"Radon"
"Barium"
"Cerium"
"Cesium"
"Cobalt"
"Curium"
"Erbium"
"Helium"
"Indium"
"Iodine"
"Osmium"
"Oxygen"
"Radium"
"Sodium"
"Sulfur"
"Arsenic"
"Bismuth"
"Bohrium"
"Bromine"
"Cadmium"
"Calcium"
"Dubnium"
"Fermium"
"Gallium"
"Hafnium"
"Hassium"
"Holmium"
"Iridium"
"Krypton"
"Lithium"
"Mercury"
"Niobium"
"Rhenium"
"Rhodium"
"Silicon"
"Terbium"
"Thorium"
"Thulium"
"Uranium"
"Yttrium"
"Actinium"
"Aluminum"
"Antimony"
"Astatine"
"Chlorine"
"Chromium"
"Europium"
"Fluorine"
"Francium"
"Hydrogen"
"Lutetium"
"Nihonium"
"Nitrogen"
"Nobelium"
"Platinum"
"Polonium"
"Rubidium"
"Samarium"
"Scandium"
"Selenium"
"Tantalum"
"Thallium"
"Titanium"
"Tungsten"
"Vanadium"
"Americium"
"Berkelium"
"Beryllium"
"Flerovium"
"Germanium"
"Lanthanum"
"Magnesium"
"Manganese"
"Moscovium"
"Neodymium"
"Neptunium"
"Oganesson"
"Palladium"
"Plutonium"
"Potassium"
"Ruthenium"
"Strontium"
"Tellurium"
"Ytterbium"
"Zirconium"
"Dysprosium"
"Gadolinium"
"Lawrencium"
"Meitnerium"
"Molybdenum"
"Phosphorus"
"Promethium"
"Seaborgium"
"Technetium"
"Tennessine"
"Californium"
"Copernicium"
"Einsteinium"
"Livermorium"
"Mendelevium"
"Roentgenium"
]L's+"Xenon"?

The missing elements are Darmstadtium, Praseodymium, Protactinium and Rutherfordium which are 12 or 13 characters long which means I can't print them in 13 characters each.
The idea is that the first few programs, which prints the elements with short names use their extraneous characters to build the string Chuck Norri in the variable L, which does not affect the output when used on their own. The final program then checks if anything is already on the stack, and uses it to choose between L (plus s) and Xenon.
A few additional bytes are saved by using the character we just added to L as part of the element name, specifically for Carbon, Nickel, Copper and Silver.

Python, L = 2596, N = 118, Score = 0.186
The length of each slice is 22 so that makes this pretty lengthy.
lambda:"Gold"; print"""";print "Carbon     "print   "Thorium     "print   "Curium      "print "Calcium       "print "Nickel        "print      "Zinc     "print    "Neon       "print "Boron         "print   "Iron        "print  "Cerium       "print "Barium        "print "Caesium       """[9::22];lambda:"Tin"[0];lambda:"Lead    "#print"Argon          "print"Radon          "print"Xenon          "print"Erbium         "print"Cobalt         "print"Copper         "print"Helium         "print"Indium         "print"Iodine         "print"Osmium         "print"Oxygen         "print"Radium         "print"Silver         "print"Sodium         "print"Sulfur         "print"Arsenic        "print"Bismuth        "print"Bohrium        "print"Bromine        "print"Cadmium        "print"Dubnium        "print"Fermium        "print"Gallium        "print"Hafnium        "print"Hassium        "print"Holmium        "print"Iridium        "print"Krypton        "print"Lithium        "print"Mercury        "print"Niobium        "print"Rhenium        "print"Rhodium        "print"Silicon        "print"Terbium        "print"Thulium        "print"Uranium        "print"Yttrium        "print"Actinium       "print"Antimony       "print"Astatine       "print"Chlorine       "print"Chromium       "print"Europium       "print"Fluorine       "print"Francium       "print"Hydrogen       "print"Lutetium       "print"Nitrogen       "print"Nobelium       "print"Platinum       "print"Polonium       "print"Rubidium       "print"Samarium       "print"Scandium       "print"Selenium       "print"Tantalum       "print"Thallium       "print"Titanium       "print"Tungsten       "print"Vanadium       "print"Nihonium       "print"Aluminium      "print"Americium      "print"Berkelium      "print"Beryllium      "print"Flerovium      "print"Germanium      "print"Lanthanum      "print"Magnesium      "print"Manganese      "print"Neodymium      "print"Neptunium      "print"Palladium      "print"Plutonium      "print"Potassium      "print"Ruthenium      "print"Strontium      "print"Tellurium      "print"Ytterbium      "print"Zirconium      "print"Moscovium      "print"Oganesson      "print"Dysprosium     "print"Gadolinium     "print"Lawrencium     "print"Meitnerium     "print"Molybdenum     "print"Phosphorus     "print"Promethium     "print"Seaborgium     "print"Technetium     "print"Tennessine     "print"Californium    "print"Copernicium    "print"Einsteinium    "print"Livermorium    "print"Mendelevium    "print"Roentgenium    "print"Darmstadtium   "print"Praseodymium   "print"Protactinium   "print"Rutherfordium  "

Here is the Salesman after the slicing and dicing:
lambda:"Gold"; print""  # <-- This is a function
"";print "Carbon     "
print   "Thorium     "
print   "Curium      "
print "Calcium       "
print "Nickel        "
print      "Zinc     "
print    "Neon       "
print "Boron         "
print   "Iron        "
print  "Cerium       "
print "Barium        "
print "Caesium       "
""[9::22];lambda:"Tin"  # <-- This is a function and the choke point
[0];lambda:"Lead    "#  # <-- This is a function
print"Argon          "
print"Radon          "
print"Xenon          "
print"Erbium         "
print"Cobalt         "
print"Copper         "
print"Helium         "
print"Indium         "
print"Iodine         "
print"Osmium         "
print"Oxygen         "
print"Radium         "
print"Silver         "
print"Sodium         "
print"Sulfur         "
print"Arsenic        "
print"Bismuth        "
print"Bohrium        "
print"Bromine        "
print"Cadmium        "
print"Dubnium        "
print"Fermium        "
print"Gallium        "
print"Hafnium        "
print"Hassium        "
print"Holmium        "
print"Iridium        "
print"Krypton        "
print"Lithium        "
print"Mercury        "
print"Niobium        "
print"Rhenium        "
print"Rhodium        "
print"Silicon        "
print"Terbium        "
print"Thulium        "
print"Uranium        "
print"Yttrium        "
print"Actinium       "
print"Antimony       "
print"Astatine       "
print"Chlorine       "
print"Chromium       "
print"Europium       "
print"Fluorine       "
print"Francium       "
print"Hydrogen       "
print"Lutetium       "
print"Nitrogen       "
print"Nobelium       "
print"Platinum       "
print"Polonium       "
print"Rubidium       "
print"Samarium       "
print"Scandium       "
print"Selenium       "
print"Tantalum       "
print"Thallium       "
print"Titanium       "
print"Tungsten       "
print"Vanadium       "
print"Nihonium       "
print"Aluminium      "
print"Americium      "
print"Berkelium      "
print"Beryllium      "
print"Flerovium      "
print"Germanium      "
print"Lanthanum      "
print"Magnesium      "
print"Manganese      "
print"Neodymium      "
print"Neptunium      "
print"Palladium      "
print"Plutonium      "
print"Potassium      "
print"Ruthenium      "
print"Strontium      "
print"Tellurium      "
print"Ytterbium      "
print"Zirconium      "
print"Moscovium      "
print"Oganesson      "
print"Dysprosium     "
print"Gadolinium     "
print"Lawrencium     "
print"Meitnerium     "
print"Molybdenum     "
print"Phosphorus     "
print"Promethium     "
print"Seaborgium     "
print"Technetium     "
print"Tennessine     "
print"Californium    "
print"Copernicium    "
print"Einsteinium    "
print"Livermorium    "
print"Mendelevium    "
print"Roentgenium    "
print"Darmstadtium   "
print"Praseodymium   "
print"Protactinium   "
print"Rutherfordium  "

Update

[16-09-08] Sublime added an extra space when joining to a line that ends in a comment character
[16-09-08] Made each slice 22 characters long and added gif

I'm fairly knew at Python, how does lambda:"Actinium";print"" output Actinium? Is this maybe particular to Python 3?

@Linus The lambda key word creates an anonymous function that takes no parameters and returns Actinium. The print "" doesn't do anything useful after the Salesman has been dismembered.

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


text:
Print multiplication tables by input
In this challenge you've to print multiplication tables by input, Here are some examples:
Input: 2

Output:
0 2  4 6 8  10  12  14  16  18  20

Input: 20

Output: 20 40 60 80 100 120 140 160 180 200

Rules

The shortest code in bytes wins.
This challenge is a code-golf, It follows code-golf general rules (code-golf)
If, just if, your code can't print number, you can use letters, Here is an example:
Input: B
Output: B D F H J L N P R T
You can choose to start from 0 or your number (like 20). You can choose if put spaces or don't. The challenge is free, just take an input and print multiplication tables.
Your output must list the first 10 members of the times table for the given number. You may leave out 0*n.

Your first example has multiples from 0 to 10, the second from 1 to 10. Can we choose either of these or is one of them a typo? Also, does output have to be space-separated or can we use other list-formats? (If only spaces, the number of spaces is a bit random in your example.)

You can choose to start from 0 or your number (like 20). You can choose if put spaces or don't. The challenge is free, just take an input and print multiplication tables.

Welcome to PPCG! Nice to see a pretty simply challenge, since we don't have these enough, although in the future I would add some more information. Like: From the test cases it seems we only need to output 10 numbers, but I don't see this specified. Do we need to support negative input? Why are there two spaces between 2 and 4? Why does the first test case have the 0 in it's output (making it 11 output numbers instead of 10). etc. etc. Also, the Sandbox for proposed challenges is a good place to post first to perfect the challenge

Under rule 3, what should the output for C be? How about Z?

What exactly is the output, the normal rules tend to allow a function to return its output as a list rather than printing them to STDOUT.

MATL, 4 bytes
10:*

Breakdown:
        % Implicit input
10:     % Create a list from 1 2 ... 10
   *    % Multiply list by input
        % Implicit output

Try it online

C#, 105 96 67 56 bytes
Now that I know how lambda's work in C#, here is an update to my first answer:
n=>{for(int i=0;i++<10;)System.Console.Write(i*n+" ");};

Saves 11 bytes.

First post, please forgive me for anything I've done wrong.  Also, feel free to give me golfing tips, as I haven't really tried it before!
void c(int n){for(int i=0;i++<10;){System.Console.Write(i*n+" ");}}

Ungolfed:
void c(int n)
{
    for (int i = 0; i++ < 10 ; )
    {
        System.Console.Write(i*n+" ");
    }
}

Thank you Jonathan Allan, can't add comments yet.
And thank you Kevin Cruijssen.  I assumed I had to always include the entire program unless the question specified that snippets were allowed.  Would I also be able to leave out the System. call to print to console in this case, or are using/imports required then?

Welcome to PPCG! You can remove the class, only the main function is required by golfing rules :)

@JonathanAllan Not only that, but by those same rules you can also just make a separate method without Main altogether. I.e. void f(int n){for(int i=0;i++<10;){System.Console.Write(i*n+" ");}} And indeed, welcome to PPCG!

http://codegolf.stackexchange.com/q/173/39436

Jelly, 3 bytes
⁵R×

Test it at TryItOnline
Or first 256 cases, nicely aligned, also at TryItOnline
How?
⁵R× - main link takes one argument, n
⁵   - literal 10
 R  - range [1,2,...,10]
  × - multiply by input (implicit vectorization)

I'd love to learn Jelly but half the commands don't render for me, so it'd be useless :D

@BetaDecay I can't type most of them and they don't render for me in any text editor or on my cmd line :( - they render fine in Firefox on my Windows 7 machine though.

You and Emigma are winning.

@BetaDecay - It could help you to download and (re)install DejaVu Sans Mono font (I can now see almost every character in notepad++ and TIO through Firefox is now using it too and displaying every character still)

Exactly what I thought of, +1.

Clojure, 70 80 bytes
This is my first post on CG, I hope the input is OK:
70 bytes
(defn -main[& a](println(map #(* %(read-string(first a)))(range 10))))

80 bytes
(defn -main[& a](let[n(read-string(first a))](println(map #(* % n)(range 10)))))

The program will read a number as a stdin argument and display the result:
Output
lein run 10
(0 10 20 30 40 50 60 70 80 90)

Welcome! That's a great first answer!

05AB1E, 3 bytes
TL*

Explanation
T    # literal predefined  as 10
 L   # 1-based range: [1,2,3,4,5,6,7,8,9,10]
  *  # multiply with input

Try it online!

You and Jonathan Allan are winning

Perl, 19 bytes
Includes +1 for -n
Run with the input on STDIN:
perl -M5.1010 -n table.pl <<< 8

table.pl:
say$_*$`for/$/..10

You probably meant -n ? or did I miss something?

@Dada: right, conflated it with another version. Fixed

Haskell, 16 bytes
(<$>[1..10]).(*)

Usage example: (<$>[1..10]).(*) $ 4 -> [4,8,12,16,20,24,28,32,36,40].
Pointfree version of: f n = map (n*) [1..10].

What does <$> do?

@Cyoce: <$> is an infix version of fmap (or map when used with a list), i.e. it applied the function given as it's 1st argument to every element of the list. func <$> list= fmap func list= map func list.

Jellyfish, 8 bytes
p*r11
 i

Try it online!
Quite simple: r11 gives the list [0, 1, ..., 9, 10], i reads the input, * multiplies them and p prints the resulting list.

PHP, 34 bytes
(34 bytes)
for(;$i++<10;)echo$i*$argv[1].' ';

(34 bytes)
for(;++$i%11;)echo$i*$argv[1].' ';

(34 bytes)
while($i++<10)echo$i*$argv[1].' ';

(35 bytes)
for(;$i++<10;)echo' '.$a+=$argv[1];

(41 40 bytes)
<?=join(' ',range(0,10*$a=$argv[1],$a));

<?=join(' ',range($a=$argv[1],10*$a,$a));

(44 bytes)
foreach(range(1,10)as$i)echo$i*$argv[1].' ';

The one using range() with $step can be shorter if you start it from 0: <?=join(' ',range(0,10*$a=$argv[1],$a));.

The rule allowing to start from 0 was not set when I did it, but you're right; I update this one.

R, 11 bytes
scan()*0:10

30 char.

J, 8 bytes
(i.10)&*

This is the range from 0 to 9 inclusive (i.10) bonded (&) wit the multiplication function (*). This starts at zero.
Test cases
   k =: (i.10)&*
   k 2
0 2 4 6 8 10 12 14 16 18
   k 10
0 10 20 30 40 50 60 70 80 90
   k"0 i.10
0 0  0  0  0  0  0  0  0  0
0 1  2  3  4  5  6  7  8  9
0 2  4  6  8 10 12 14 16 18
0 3  6  9 12 15 18 21 24 27
0 4  8 12 16 20 24 28 32 36
0 5 10 15 20 25 30 35 40 45
0 6 12 18 24 30 36 42 48 54
0 7 14 21 28 35 42 49 56 63
0 8 16 24 32 40 48 56 64 72
0 9 18 27 36 45 54 63 72 81

Python 3, 52 33 30 bytes
lambda n:list(range(0,11*n,n))

3 bytes saved thanks to @manatwork
Formatting the output is visibly not necessary

Borrow from my shell answer: lambda n:" ".join(map(str,range(0,n*11,n)))

@manatwork I use Python 3

You use Python 3 but you can save 6 bytes by using Python 2: lambda n:range(0,11*n,n)

Author AFK for a year. new answer 26 bytes.

Zsh, 19 characters
echo {0..${1}0..$1}

Sample run:
(This is the interactive way to run it, equivalent with zsh scriptfile.sh 20.)
~ % set -- 20

~ % echo {0..${1}0..$1}
0 20 40 60 80 100 120 140 160 180 200

Java 7, 61 57 bytes
void c(int n){for(int i=0;i++<10;)System.out.print(i*n);}

Ungolfed & test cases:
Try it here.
class M{
  static void c(int n){
    for(int i = 0; i++ < 10; ){
      System.out.print(i*n);
    }
  }

  public static void main(String[] a){
    c(2);
    System.out.println();
    c(20);
  }
}

Output:
2468101214161820
20406080100120140160180200

Spaces are optional, System.out.print(i*n); would save 4 bytes

@CameronD17 Ah, that rule has been added after I made this answer, but thanks for mentioning. I've removed it.

Mata, 15 29 Bytes
args i
mata
A=1..10
B=`i'*A
B

Mata is the matrix programming language in the Stata commercial statistics package. Code creates a matrix, multiplies by the input (2 in this case) and the outputs the new matrix
Output
        1    2    3    4    5    6    7    8    9   10
    +---------------------------------------------------+
  1 |   2    4    6    8   10   12   14   16   18   20  |
    +---------------------------------------------------+

How is it taking input? It needs to be reusable too.

OK, have edited to clarify receipt of input

Pure Bash, 18
echo $[{0..10}*$1]

The input is taken as a command-line parameter.

Good & great ^_^

JavaScript (ES6), 33 31 bytes
f=(x,i=11)=>--i&&f(x,i)+" "+x*i

It's a recursive solution.

Stata, 46 bytes
args i
set obs `i'
gen x=_n
gen y=x*`i'
list y

Output
For i=15
    +-----+
    |   y |
    |-----|
 1. |  15 |
 2. |  30 |
 3. |  45 |
 4. |  60 |
 5. |  75 |
    |-----|
 6. |  90 |
 7. | 105 |
 8. | 120 |
 9. | 135 |
 10.| 150 |
    |-----|
 11.| 165 |
 12.| 180 |
 13.| 195 |
 14.| 210 |
 15.| 225 |

There are a few extra shorthands you can use here: ob for obs, g for gen, and l for list. Also, is it possible to have x be _n*`i' instead of using two variables?
I'd never seen args before in STATA. Thanks for showing me something new!

Cheddar, 20 bytes
n->(|>11).map(n&(*))

Yay for functional \o/
I don't think this needs explanation but if you'd like to me add one just ask :)

I should learn Cheddar. And what does n&(*) do? I'm assuming (*) means the same thing it means I'm haskell, but what does & do in that context?

@Cyoce it's  bonding

T-SQL 61 bytes
Replace n with the number for which table needs to be populated. Demo
SELECT TOP 11 number*n FROM master..spt_values WHERE type='P'

spt_value is a undocumented table in SQL Server, you can read more about this table in

Purpose and meaning of spt_values table
What does Spt_value means

I hope someone will come up with better TSQL solution.

Scala, 24 bytes
(n:Int)=>0 to 10 map(n*)

Explanation:
(n:Int)=> //define an anonymous function
  0 to 10 //create a range from 0 to 10
  map(n*) //multiply each element by the input

MATLAB, 12 bytes
@(x)x*[1:10]

Not really much to it. An anonymous function that takes x as input and multiplies it by the vector [1:10]. Displays as ans = 2  4  6 ... Also works in Octave.
Try it online.

Pyke, 5 bytes
TSQm*

Try it here!
Or TQm* if allowed to do numbers 0-9 rather than 1-10
Or TL* if we're going non-competitive.

Brachylog, 12 bytes
,10y:[?]z:*a

Try it online!
I need to implement that I * [A, B, C] = [I*A, I*B, I*C]…
Explanation
,10y            The range [0, 1, …, 10]
    :[?]z       The list [[0, Input], [1, Input], …, [10, Input]]
         :*a    The list [0*Input, 1*Input, …, 10*Input]

JavaScript, 42 bytes
function f(a){for(i=0;i<11;i++)alert(i*a)}

I don't know JS very well, can you move the increment into the test portion of the for?

I edited it. It's ok now.

It alerts now with alert().

It was alerting for me without alert: here - I take that back, need to click "run" not just "try" to reload

@JonathanAllan What?

...for(i=0;i++<10;) works too though, for the 1*, 2*, ... option

ES6 syntax: f=a=>{for(i=0;i++<10;)alert(i*a)} (33 characters)

brainf***, 84 bytes
,[>+>++>+++>++++>+++++>++++++>+++++++>++++++++>+++++++++>++++++++++<<<<<<<<<<-]>[.>]

Expects input as a single byte (as BF can only operate on numbers up to 255) and returns results as single bytes.  Some values may look like ASCII, but they should not be treated as such; look at the decimal representation of the returned bytes.
Try it online!

You can save 5 bytes by doing >,[>+>++>+++>++++>+++++>++++++>+++++++>++++++++>+++++++++>++++++++++[<]>-]>[.>]

@Jeff Unfortunately, that breaks any input that's higher than 25 because the byte will overflow, resetting to 0.  The overflow 0s get matched by [<], which makes the entire process loop infinitely.

Right, but overflowing bytes result in incorrect outputs with your code anyway, don't they?

@Jeff They're correct outputs, they're just operating in mod 255.

Scala, 41 35 bytes
Usage scala multiplicationtable.scala <input>
Code
print(1 to 10 map(args(0).toInt*))

You can drop the dots and some parentheses: 1 to 10 map(_*args(0).toInt)map print

Racket 31 bytes
(λ(n)(for/list((i 11))(* n i)))

Saved 7 bytes using suggestion by @StevenH "define(f n)"  replaced by "λ(n)".
Testing:
(f 2)
'(0 2 4 6 8 10 12 14 16 18 20)

(f 20)
'(0 20 40 60 80 100 120 140 160 180 200)

(f 7)
'(0 7 14 21 28 35 42 49 56 63 70)

(f 19)
'(0 19 38 57 76 95 114 133 152 171 190)

You can use a lambda λ to save 6 bytes: (λ(n)(for/list((i 11))(* n i)))

PowerShell v2+, 23 bytes
param($n)1..10|%{$_*$n}

Takes input via command-line argument, loops over the range 1 to 10, each loop placing that number *$n on the pipeline. Output via implicit Write-Output at end of program execution results in newline separated values.
PS C:\Tools\Scripts\golfing> .\multiplication-table.ps1 2
2
4
6
8
10
12
14
16
18
20

PS C:\Tools\Scripts\golfing> .\multiplication-table.ps1 20
20
40
60
80
100
120
140
160
180
200

C89, 44 bytes
k;main(n){for(k=n*11;k-=n;)printf("%d ",k);}

Ungolfed:
k;
main(n)
{
    for (k=n*11 ; k-=n ;)
        printf("%d ", k);
}

Compile and run with (input 4)
gcc -ansi main.c && ./a.out 2 3 4

Output
40 36 32 28 24 20 16 12 8 4

Test it
Demo

Groovy (39 bytes for dynamic, 21 for static):
Dynamic (39 bytes)
{a,b,c->(a..b).collect{it*c}}(1,10,2)

a is the starting point of the table
b is the ending point of the table.
c is the factor

(1, 10, 2) would print:
2
4
6
8
10
12
14
16
18
20

Try it here:
https://groovyconsole.appspot.com/edit/5194081252671488

Partial Dynamic (29 bytes)
{n->(1..10).collect{it*n}}(2)

Try it here: {same website, I can't post 3 links}/5080994763767808

Static (21 bytes)
(1..10).collect{it*2}

Try it here: https://groovyconsole.appspot.com/script/5110807876599808

Original Post Mistakes
Edited because someone pointed out I had made mistakes, original version was:
def x(a,b,c){[a..b].each{println it*c}}

Mistakes were:

Not including the call to the closure in the byte-count.
[a..b] instead of (a..b).

Without dynamic input's it is:
def x(c){[1..10].each{println it*c}}

I'm afraid if your code expects a value required to work, other then the specified input, that has to be included in the length count. So better go with the hardcoded 1..10 range. By the way, anonymous functions/procs/lambdas/closures are acceptable: {c->(1..10).each{println it*c}} http://pastebin.com/FWBtSy77 Oh, could you specify your Groovy version? In 2.4.5 your code produces strange output: http://pastebin.com/6s0yeUx8

As there are some other solutions that output the language's native list representation, here it is in Groovy: {print((1..10)*.multiply(it))}.

I updated it based on your comments, and I actually did make some mistakes in the initial posting as well.

Groovy version didn't matter it was the [1..10] instead of using (1..10), which made it a 2D array which made it completely different haha.

Javascript (ES6), 34 31 bytes
a=>{for(i=0;i<11;)alert(++i*a)}
(a)=>{for(i=0;i<11;++i)alert(i*a)}

Saved 3 bytes thanks to grizzly.

At the very least you don't need the parentheses around the a, but I think it's also possible to be creative as to the position of the ++.

Brain-Flak 50 46 bytes
Try it online
<>((()()())({}){}){({}[()]<(({})<>({})<>)>)}{}

Explanation
Switch to the off stack and push 9:
<>((()()())({}){})

Decrement the nine until zero
{({}[()]<...>)}{}

Each time add the input value a copy of the top value
(({})<>({})<>)

Cubix, 24 bytes
;;..I1.N-?W.;;)W@/So..*O

Cubix is a 2-dimensional, stack-based esolang. Cubix is different from other 2D langs in that the source code is wrapped around the outside of a cube.
Test it online! Note: you'll have to copy-paste the code, and there's a 50 ms delay between iterations.
Explanation
The first thing the interpreter does is figure out the smallest cube that the code will fit onto. In this case, the edge-length is 1. Then the code is padded with no-ops . until all six sides are filled. Whitespace is removed before processing, so this code is identical to the above:
    ; ;
    . .
I 1 . N - ? W .
; ; ) W @ / S o
    . .
    * O

Here's a slightly shorter one using the new stack options I.0.WrN;-!@vrW>r)*O;o

Pyth, 5 Bytes
Try It Online
VhT*N

explanation
V    for unary_range(
hT   Ten+1)
*N   Print (N *Input)

Example
===================== Input ======================
20
==================================================

0
20
40
60
80
100
120
140
160
180
200

3d, 35 bytes
Code:
>#a…:>×=$v
   ;, !a#—v
     ^ ! '<

Explanation:
#a push 10
…  push every number in the range top..1 (=> 10..1)
:  input number
×  push product of top two of the stack
=  output as number
$  invert top two of the stack
—  pops stack and check if null
if is null:
    #a! print newline
    ,;  pops silently and exits
if not:
    ' ! print a space
... and loops back to ×

Dyalog APL, 5 bytes
Begins at 0× or 1× depending on ⎕IO.
⎕×⍳10

⎕ input
× times
⍳10 first 10 integers
TryAPL online: with ⎕IO←0
and
with ⎕IO←1
.

Perl 6, 10 bytes
{$_ X*^11}

Explanation:
{
  # the input
  $_

  # crossed using &infix:<*>
  X[*]

  # a Range from 0 to 11 excluding 11
  # ( short for ｢0 ..^ 11｣ )
  ^11
}

say {$_ X*^11}(20)
# (0 20 40 60 80 100 120 140 160 180 200)

Forth, 31 bytes
Pretty simple answer. Leaves n on the stack.
: f 10 0 DO dup I 1+ * . LOOP ;

Try it online

Befunge 93 : 24 bytes
&:01+*.20g1+:"9"`#@_20p#

Fairly straightforward. Uses get and put instructions to keep track of the iterator.

Sesos, 12 bytes
~~

Since this contains unprintables, here is an xxd reversible hexdump:
0000000: d6cb82 06efbe 7e7ed0 ef1fcf                       ......~~....

The SASM that was used to compile the above SBIN is here:
set numin            ;Input consists of linefeed-separated integers from now on.
set numout           ;Output consists of linefeed-separated integers from now on.
get                  ;Get the input.
fwd 1                ;Go to the repeat-count cell.
add 10               ;Repeat 10 times.
jmp                  ;Enter the loop.
 sub 1                ;This is a repeat-n-times loop.
 rwd 1                ;Go to the proper cell.
 jmp                  ;Table generation method.
  sub 1                ;Value copying.
  fwd 2                ;Go to the multiple cell.
  add 1                ;Add the value.
  fwd 1                ;Go to an empty cell.
  add 1                ;Copy the original value, so that we don't lose it.
  rwd 3                ;Enable finishing check.
 jnz                  ;Check if the method is finished.
 fwd 3                ;Where the original value has been copied.
 jmp                  ;Move the value back to its original place.
  sub 1                ;Empty the cell.
  rwd 3                ;Go to the original cell.
  add 1                ;Set it to the original value.
  fwd 3                ;Enable finishing check.
 jnz                  ;Check if the moving is finished.
 rwd 1                ;Go to the multiply cell.
 put                  ;Print its value.
 rwd 1                ;Enable finishing check.
                     ;(implicit jnz) Check if execution should be terminated.

Try it online!
Output is like this:
1
2
3
4
5
6
7
8
9
10

Fourier, 15 bytes
I~N11(i*Noi^~i)

Output for input 20:
020406080100120140160180200

Since unseparated output is allowed.
Try it online!

Pyth, 7 bytes
m*dQU11

Input: 2
Output: [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]

Prints as a list, but can print as seen in the question with a simple modification, making it 9 bytes.
jdm*dQU11

Input: 20
Output: 0 20 40 60 80 100 120 140 160 180 200

Neoscript, 16 bytes
{n|0:[n]:(10*n)}

Inspired by @manatwork answer

LI, 30 bytes
M1iM2iM3iM4iM5iM6iM7iM8iM9iMY9

The lack of a working list implementation does not win me any awards today.

Labyrinth, 41 bytes
First time trying to use Labyrinth.  I have no idea how to take advantage of grid manipulation, so I ignored it in my answer.  There's probably certainly better ways to do this, but I don't know how to do it.
10}
  ?
: :
:::
  :
":"
"
!\{(@
"  }
":+"

Try it online!

If it's any consolation, apart from a couple of very specific use cases I also don't know how to take advantage of grid manipulation. ;)

One such use case is to start with a long piece of linear code "for free" though: http://labyrinth.tryitonline.net/#code=PDo6Ojo6Ojo6Oj99MDEKOgohXHsoQAoiICB9CiI6KyI&input=NQ&debug=on (although I'm sure there must be a way that avoids duplicating 10 times)

Python 2, 24 bytes
lambda n:range(0,11*n,n)

range() in Python 2 returns a list, so there is no need to convert.

That one uses Python 3. This one uses Python 2. The code is shorter by 6 bytes. Therefore, it is not a duplicate.

@OliverNi Yes, it is, since it uses the same method, and is the same language, just different version. The other one using list is just because Python 3's range is equivalent to Python 2's xrange.

Japt, 6 bytes
UòA*UU

Test it online!
How it works
        // Implicit: U = input integer, A = 10
Uò      // Create a range from U to
  A*U   //  10 * U,
     U  //  skipping by U each time.
        // Implicit: output last expression

Bash on OSX, 13
jot 11 0 - $1

The input is taken as a command-line parameter.  This will also work on Linux is jot is installed; e.g. sudo apt-get install athena-jot.

Can't you use jot 11 0 -$1?

@Rizze I don't think so - that would could down from 0 to $1 * -1 in 11 steps

Mathematica, 10 bytes
#Range@10&

Range@10 is the list {1,2,...,10}, which is then multiplied by the input #.

C, 39 bytes
i;F(n){while(i<11)printf("%d ",n*i++);}

Ideone it!

Input:
10

Output:
0 10 20 30 40 50 60 70 80 90 100

PHP, 44 bytes
$a=$argv[1];for($i=0;$i<10*$a;$i+=$a)echo$i;

You can remove 1 byte using echo$iinstead of echo$i;.

And how you run it? Without the semicolon I get only error: http://pastebin.com/uGbRA6KA

@manatwork true, i didn't even check before editing, my bad

jq, 15 characters
range(0;.*11;.)

Sample run:
bash-4.3$ jq 'range(0;.*11;.)' <<< 20
0
20
40
60
80
100
120
140
160
180
200

On-line test

Can't you use range(0;.*11)?

@Rizze, then step defaults to 1, so for 20 will not output 0, 20, 40, …, 200, but 0, 1, 2, …, 219.

Oh ok, Can't you just delete . or ;?

Nope. . is kind of default variable, something like $_ in Perl and it in Groovy. ; is the parameter separator, like , in most programming language. To use range() with step, you have to pass 3 parameters and none of them can be empty.

Ah ok :) Understood

Retina, 63 bytes
Feels a bit long...
$
¶10$*
+`¶(1(1+))
¶$2 $1
^.+
$*
(?<=(1+)¶.*)1
$1
.*¶

(1)+
$#1

Try it online

Pyth, 5 bytes
*RQST

If we're allowed to print the table from 0-9, *RQT would work as well.  Outputs in list [2, 4, 6, 8,...] form.

C#, 62 bytes
void P(int x){for(int i=1;i<=10;i++){Console.WriteLine(x*i);}}

Python 3:
The current Python 3 answer has several flaws:

the author hasn't been online for a year.
does not count the print, and this answer, and possibly others, requires it built-in.

This answer, not counting the input n=2 and the print() has 26 Bytes, which beats the current best.
Counting everything (which is much easier to compare): 36 bytes.
I suggest this to be the updating answer.
n=2;s=0
while s<11: print(s*n); s+=1

Try it online!

brainfuck, 37 bytes
,<++++++++++[->[->+>+<<]>[-<+>]>.<<<]

Try it online!
Same IO as this

Vyxal, 3 bytes
₀ɾ*

Try it Online!
10-range-product-by-input

Thunno 2, 3 bytes
TR×

Attempt This Online!
Explanation
TR×  # Implicit input
T    # Push 10
 R   # One-range
  ×  # Multiply
     # Implicit output

J-uby, 15 bytes
:& &:*|~:*&10.+

Not much shorter than the equivalent Ruby:
->n{(1..10).map{n*_1}}

Attempt This Online!


text:
Stringsplode the String!
The challenge is relatively simple, but will hopefully lead to some wonderfully creative answers. The task is to take a string as an input (via command line, function parameter etc.) and output/return a stringsploded version of it.
A stringsploded version of a string is its first letter followed by its first 2 letters, followed by its first 3 letters,... until you finally output the complete word.
You are guaranteed that the input will consist of printable ASCII characters and that the input will all be on one line (no new line characters).
Here are examples to clarify what stringsplosions are:
Input                 Output
==================================================================
"Code"       ---->   "CCoCodCode"
"name"       ---->   "nnanamname"
"harambe"    ---->   "hhaharharaharamharambharambe"
"sp aces?"   ---->   "sspsp sp asp acsp acesp acessp aces?"
"1234"       ---->   "1121231234"
"ss"         ---->   "sss"

This is code golf so shortest code wins + up votes for interesting uses of your respective language.
Good luck!

Will the input only contain letters?

@MartinEnder The input is a string that could contain anything that a string would normally contain (limited to ASCII I suppose). Is there an ambiguous area that I haven't addressed?

String challenges should usually specify the valid input characters, because it's not clear whether the input may contain a) non-letters, b) unprintable/control characters, c) null bytes, d) extended ASCII characters, e) Unicode characters beyond code point 256, (... f) combining marks, g) surrogates ...), all of which can arbitrarily complicate the challenge in many languages. And since your test cases only cover letters one might assume that that's your intended input range.

You should add a test case where the first two characters are the same.

As someone with a stutter, I'm OOfOffOffeOffenOffendOffendeOffended.

@BasicallyAlanTuring  You sir have a beautifully structured stutter; my OCD is pleased.

Alternate title: SStStrStriStrinStringStringsStringspStringsplStringsploStringsplodStringsplode

@DJMcMayhem I would gladly use that.

May there be extra whitespace? May we return a list of {"C","Co","Cod",...?

@Adám You need to output/return a single string so you would need to flatten the list. As for the extra whitespace, only trailing whitespace at the end is allowed.

Reeelelelaelaelatelatelateelateelatedelated.

Also related, near duplicate.

Damn I searched so long looking for possible duplicates.

Literally no point closing this. 43 answers and literally no one cares that it's a duplicate of an 8 month old post.

@MartinEnder Since the requirements are more lenient there, all solutions here are valid there too. Shouldn't this post's answers posts migrated and this post removed?

@Adám If that were to happen, there's not doubt that some answers would be duplicates or each other.

gs2, 1 byte
x

gs2 takes input from STDIN, and pushes it to the stack as a string.
x is the prefixes built-in, returning a list of all prefixes of the argument, in ascending-length order.
The resulting list of strings is implicitly printed one-by-one, without a delimiter, when the program terminates.

Wow Speechless automagic wizardry

Jelly, 2 bytes
;\

Acculumate over concatenation gives all prefixes, which Jelly outputs to STDOUT without a delimiter. Try it online!

Oh, cumulative reduce and reduce never seem to do what I expect. Surely a winner! Test cases

@JonathanAllan Uh oh, Lynn did 1 byte :D

Retina, 4 bytes
.
$`

Expects the input to be terminated with a Windows-style \r\n newline (which seems fitting for a .NET-based programming language...).
This can be tested on Regex Storm (which uses \r\n newlines). Click the "Context" tab for the result.
This is essentially the same as Jordan's Ruby answer: it replaces each character in the input (including the \r but not the \n) with all the characters that came before it.

Java 7, 81 78 bytes
String g(String a){for(int i=a.length();i>0;)a=a.substring(0,--i)+a;return a;}

Straightforward method. Repeatedly prepends the shrinking prefix until it's done.
As a bonus, it should work for non-ASCII as well.
Sample:
Input:  ( ͡° ͜ʖ ͡°)
Output: (( ( ͡( ͡°( ͡° ( ͡° ͜( ͡° ͜ʖ( ͡° ͜ʖ ( ͡° ͜ʖ ͡( ͡° ͜ʖ ͡°( ͡° ͜ʖ ͡°)

You've beat me to it. Also, +1 I like the Lenny Face example.

Haha, yes. I like to think of it as Lenny sliding into the room Kramer style when he hears something "appropriate".

Jelly, 5 4 2 bytes
-2 bytes thanks to @Dennis
ḣJ

Test it at TryItOnline
Or all test cases, also at TryItOnline
How?
ḣJ - Main link takes one argument, e.g. "Code"
 J    - range(length(input)), e.g. [1,2,3,4]
ḣ    - head, x[:y] (implicit vectorization), e.g. "CCoCodCode"

ḣJ works too.

@Dennis heh, forgot about J  :)

Brachylog, 11 5 bytes
:@[fc

Try it online!
Explanation
:@[f           Find all prefixes of the input
    c          Concatenate

MATL, 9 8 6 bytes
2 bytes saved thanks to @Luis
t&+Rf)

Try it Online!
Explanation
t       % Implicitly grab the input and duplicate
&+      % Broadcast and create a 2D matrix with all values > 0
R       % Grab the upper triangular portion (sets the lower triangular values to 0)
f       % Get the linear index for each value > 0
)       % Index into the original string (uses modular indexing)
        % Implicitly display the result

Cool Solution! (as MATL answers tend to be)

05AB1E, 3 bytes
.pJ

Explanation
.p   # get list of prefixes of input
  J  # join as string

Try it online!

Damn... I retire

That .p idea was a goodun

@JonathanAllan: A prefix command does come in handy now and then yeah :)

Well.... Shoot.

Ruby, 13 + 1 = 14 bytes
+1 byte for -p flag. Expects input on STDIN. Requires Windows-style line endings (\r\n).
gsub(/./){$`}

See it on eval.in (a few extra bytes since eval.in doesn't support command line flags):
https://eval.in/637093

I think this only works with \r\n newlines. Otherwise, . doesn't have the last character to match (since it doesn't match \n).

@MartinEnder I was actually just wondering why this works. That explains it. I forgot eval.in uses \r\n. I'll write a version that works with conventional newlines.

I think assuming \r\n newlines is fine since that's the default on Windows (and in your online interpreter apparently). But you should mention it in the answer.

I was going to post a Retina answer but it would now be straight port of yours, so if you want to post it yourself, it's simply . on the first line and `$`` on the second.

@MartinEnder If you want to post it I won't take it personally. It's a pretty obvious solution so I don't feel proprietary about it.

Javascript (ES6), 28 26 bytes
Recursively appends the shortened strings to the left of the final result:
f=s=>s&&f(s.slice(0,-1))+s

Examples

var
f=s=>s&&f(s.slice(0,-1))+s

console.log(f("Code"));     //  -->   "CCoCodCode"
console.log(f("name"));     //  -->   "nnanamname"
console.log(f("harambe"));  //  -->   "hhaharharaharamharambharambe"
console.log(f("sp aces?")); //  -->   "sspsp sp asp acsp acesp acessp aces?"
console.log(f("1234"));     //  -->   "1121231234"

Smart use of recursion +1

JavaScript (ES6), 25 bytes
s=>s.replace(/./g,'$`$&')

Haskell, 34 29 28 26 bytes
reverse=<<scanl(flip(:))[]

I'm just sad I can't use join.inits since neither of those are in the Prelude.

@ballesta25 I know, FeelsBadMan.

Hmm, concat.scanl(flip(:))[] $ "Code" -> "CoCdoCedoC". Each part (1st letter, 1st+2nd letter, ...) is in reverse.

@nimi is right. It needs to be reverse=<<scanl(flip(:))[]

Perl, 10 bytes
Includes +1 for -p
Run with the input on STDIN:
splode.pl <<< "Hello"

splode.pl
#!/usr/bin/perl -p
s/./$`/sg

This depends on the input being terminated by a newline. This 11 byte version does not need a final newline:
#!/usr/bin/perl -lp
s/.?/$`/g

CJam, 8 bytes
Here's 4 separate ways to get 8 bytes
l_,),\f<
l{1$\+}*
l{+_}*co
Ll{+_}/;

Credits to @MartinEnder for the last one. Online interpreter.

l_,),\f< creates the range [0 .. len(s)+1] then uses f< to slice for each number, producing all prefixes.
l{1$\+}* is a fold that duplicates the previous prefix and adds a char to it as it goes.
l{+_}*co is a bit weird - l{+_}* is also a fold but it produces the wrong prefixes, skipping the first and doubling the last (e.g. abcd -> ab/abc/abcd/abcd, slashes for clarity). We then use c to turn the last string into just its first character and output it with o, to get the first prefix.
Ll{+_}/; is a for-each loop that also duplicates the previous prefix and adds a char to it as it goes. We have an extra copy of the original string once the loop is over, which we pop with ;.

Python, 34 28 bytes
Here's my rough attempt with a recursive solution:
f=lambda s:s and f(s[:-1])+s

Ungolfed:
def f(s):
    if s: return f(s[:-1]) + s
    return ''

Try it here!
Thanks to @Dennis for -6 bytes.

I got ninja'd by recursives..... 300th time...

f=lambda s:s and f(s[:-1])+s saves 6 bytes.

Pretty sure you can remove the f=

@OliverNi How would I make the recursive call?

C, 49 bytes
i;f(char*n){for(i=0;i++<strlen(n);)write(1,n,i);}

Try on Ideone

You can golf it down to 41 bytes i;f(char*v){while(*(v+i))write(1,v,++i);}

C#, 91 87 84 83 bytes
void c(string n){var b="";for(int i=0;i<n.Length;)System.Console.Write(b+=n[i++]);}

Ungolfed:
void c(string n)
{
    var b = "";
    for (int i = 0; i < n.Length ; )
    {
        System.Console.Write(b+=n[i++]);
    }
}

Thank you Kevin Cruijssen.

+1 You can golf a few things, though. string b=""; can be var b=""; and i++ can be removed in the for-loop and added to the usage of i. So in total it becomes: void c(string n){var b="";for(int i=0;i<n.Length;){b+=n[i++];System.Console.Write(b);}}

Ah, I can finally comment.  Thanks for the suggestions!

I've deleted my previous 84 bytes comment, because apparently it's possible to use b+= in the System.out.write.. So b=b+n[i++] can be changed to b+=n[i++] I wasn't sure if += is allowed there, but it is. Guess we both learned some things today. Sorry for making you edit all the time, and welcome to PPCG. :) Also, Tips for golfing in C# might be interesting to read through.

Haha yeah.  And for sure, I'll be checking a few tips of the languages I know.

Jellyfish, 5 bytes
P,\}I

Try it online!
Explanation
    I  # Read input.
  \}   # Get all prefixes.
 ,     # Flatten.
P      # Print.

V, 8 bytes
òÄ$xhòíî

Try it online!

sed 41
h;:;G;s,.\n,\n,;h;s,\n.*,,;/./b;x;s,\n,,g

Sesos, 4 bytes
0000000: 8073ec 09                                         .s..

Try it online! Check Debug to see the generated SBIN code.
Sesos assembly
The binary file above has been generated by assembling the following SASM code.
    jmp, rwd 1, jnz
    fwd 1
    jmp, put, fwd 1, jnz
jnz

R, 60 49 bytes
Not going to win any golf, but hopefully no shorter R answer is possible
cat(substring(s<-readline(),1,1:nchar(s)),sep="")

paste0(substring(s<-readLines(,1),1,1:nchar(s)),collapse="")

Thanks @MickyT

Well there's always cat(substring(s<-readline(),1,1:nchar(s)),sep="") :)

CJam, 11 bytes
q{(L\+:Lo}h

Explanation:
q                   get input
 {       }h         do while
  (L                get 1st character and variable L (initialized with "")
    \+              swap and concatenate them
      :Lo           store result in L and print it

Try it online

Dyalog APL, 3 bytes
∊,\

∊ flatten the
,\ cumulative concatenation
TryAPL online!

Pyth, 3 bytes
s._

Explanation:
s   (s)um together
 ._ all prefixes

Python 3, 47 bytes
Thanks to @deustice
lambda s:''.join(s[:i]for i in range(len(s)+1))

Ideone it!

You can take out the 0, just s[:i] should work

@deustice Oh, of course, thanks!

Retina, 24 bytes
Well, I got destroyed by Martin, but here was my solution.
1m+`(.*).$
$1$.1$*¶$0
¶

Try it online

PowerShell v2+, 43 bytes
param($n)-join(1..$n.length|%{$n[0..--$_]})

Takes input $n, loops from 1 to $n.length, each iteration slicing $n from 0 up to one less than the current number -- done because .length is 1-indexed, while array slicing is 0-indexed. Each iteration places characters on the pipeline, those are encapsulated in parens and -joined together into one string. Output is implicit.
PS C:\Tools\Scripts\golfing> .\stringsplode-the-string.ps1 'PPCG'
PPPPPCPPCG

Alternatively, using Jordan's Ruby submission as a basis, you can get to the following for 22 bytes
$input-replace'.','$`'

This feels kinda cheaty, though, since you'd have to explicitly insert a newline into the string that you're piping in, or otherwise do a Get-Content or something out of a file that pulls the newlines with it. Valid, but not really common.
PS C:\Tools\Scripts\golfing> 'PPCG
' | .\stringsplode-the-string.ps1 $_
PPPPPCPPCG

If I pipe a string into another program, it gets the \r\n at the end automatically. Looks like PowerShell scripts are treated differently in that regard?

@MartinEnder Yeah. I'm not sure if it's because piping in PowerShell is handled differently than piping in other shells, or because the items passed between the pipe are literal objects and there's no \r\n at the end of the literal string. Probably a combination.

C 71 67 Bytes
k;f(v){char*m,*n=v;while(*n++)for(k=0,m=v;k<n-v;k++)putchar(*m++);}

Pyke, 5 bytes
FKoh<

Try it here!
      - o = 0
FK    - for i in input:
  oh  -   1+o++
    < -  input[:^]
      - "".join(^)

What does K do?

The F automatically pushes each character to the stack, the K removes it

then I suggest you put FK on the same line in the explanation

Gema, 16 characters
?=@append{s;?}$s

Sample run:
bash-4.3$ echo -n 'sp aces?' | gema '?=@append{s;?}$s'
sspsp sp asp acsp acesp acessp aces?

GNU sed, 30 bytes
:;G;h;s/.\n.*//;/./t;g;s/\n//g

Run:
echo -n "name" | sed -f stringsplode.sed

Perl 6,  23  16 bytes
{S:g/.?/{$/.prematch}/}  # <-- the Perl 5 entry as a Perl 6 lambda
{[R~] m:ex/^.*/}
{[~] m:ex/^.*?/}

Explanation:
# bare block lambda with implicit parameter ｢$_｣
{
  # list reduce using string concatenation operator
  [~]

  # the input implicitly matched against
  m

  # in all possible ways
  :exhaustive

  /
    ^   # must match from the beginning
    .   # any character
    *?  # any number of times non-greedily
  /
}

The m:ex/^.*?/ part produces a list of Match values (｢｣,｢C｣,｢Co｣,｢Cod｣,｢Code｣).
The other option m:ex/^.*/ produces the Match values in exactly the opposite order, so they have to be combined in reverse using the R meta operator.

Lua, 58
u=''for s in io.read():gmatch('.')do u=u..s io.write(u)end

Saved 5 Bytes thanks to manatwork
I love using lua's gmatch and gsub for golfing.
Simply takes io.read(), gmatch's it for any single character, iterating through the entire string.
it assigns the variable st, which slowly builds the entire string as lua iterates, and at every iteration, writes the contents of st.

Just some general golfing things: you can choose shorter variable name and there is an unnecessary space in front of end.

Go, 90 bytes
package main;import."fmt";func main(){s:="";Scan(&s);for i:=0;i<=len(s);i++{Print(s[:i])}}

BASH (grep + sed + tr) 36
grep -o .|sed ':;p;N;$!b'|tr -d '\n'

'\n' → \\n.

PHP , 52 Bytes
for(;$i<strlen($t=$argv[1]);)echo substr($t,0,++$i);

Seems you forgot to clean up after previous attempt: variable $l is not used anymore.

PHP, 39 37 35 bytes
while($c=$argv[1][$i++])echo$s.=$c;

works for all examples. String should not countain the 0 character.
PHP, 50 40 38 bytes
while(''<$c=$argv[1][$i++])echo$s.=$c;

Racket 81 bytes
(λ(s)(apply string-append(for/list((i(+ 1(string-length s))))(substring s 0 i))))

More readable form:
(define(f s)
  (apply
   string-append
   (for/list
       ((i(+ 1(string-length s))))
     (substring s 0 i))))

Testing:
(f "Code")
"CCoCodCode"

Haskell (lambdabot), 10 bytes
join.inits

Sample:
(join.inits) "Code"
"CCoCodCode"

This doesn't work in standard Haskell, because you need imports for both join and inits which are added to the byte count. If you have an interpreter/compiler that imports them by default, please specify it as part of the language name. Thanks!

MATL, 8 bytes
"GX@:)v!

This uses a different approach from @Suever's answer.
Try it online!
Explanation
        % Implicit input: string
"       % For each. This repeats as many times as chars in the input string
  G     %   Push input again
  X@    %   Push iteration index, k (varies from 1 to input length)
  :)    %   Get k first chars from input
  v!    %   Concatenate all stack contents horizontally
        % Implicit end
        % Implicit display

Japt, 5 bytes
Uå+ q

Test it online!
How it works
       // Implicit: U = input string
Uå+    // Cumulative-reduce the input by addition.
       // This returns an array of all prefixes.
    q  // Join with the empty string.
       // Implicit: output last expression

Java 7, 74 bytes
String h(String a){int l=a.length();return l>1?h(a.substring(0,l-1))+a:a;}

or
String j(String a){return a.isEmpty()?a:j(a.substring(0,a.length()-1))+a;}

Recursive version of Geobits answer.


text:
Noah's (upgraded) ark
As preparation for the nth Exodus, Noah decides to write a program that will decide If he will let animals on his ark.  However, Noah wants to go back to grass roots. Thus he decides that the program should be as small and as simple as possible.
GOAL:
Recreate the Contrabulous Choosematron, in a way that follows evangelical stories.
INPUT:
The program is simple, and elegant, and takes in 2 inputs:
The species of animal [String]
and The animal's gender [boolean]
OUTPUT:
The program then puts out Either 'Y' or 'N', Which determines whether or not the given  animal is allowed onto the ark.
RULES:
Only one Animal of each species and gender is allowed on the ark. No more.
Your output can be any set of boolean values (true false, yes no, y n, yin yang) so long as they're easily distinguishable.
If your program should want to accept a list of input, rather than use STDIN, that's fine. However, each output has to be in corresponding order of the input (FIFO), as well as be in the exact same format as the input.
This is a golf, so the lowest byte count wins, good luck!!!!
EXAMPLE:

"Monkey" true<
y
"Monkey" false<
y
"Monkey" false<
n
"Monkey with symbols" false<
y
"monkey" true<
n

This is valid, as your program doesn't need to distinguish that Monkey, and monkey with symbols are the same thing species, however, Monkey and monkey are very much the same thing, and so the last critter would be denied.

Could you add an example to your question for completeness?

Will the species of animal only contain letters i.e. [a-zA-Z]?

@gowrath added! thanks for the suggestion!

@Riley some animals names may contain hyphens. Those animals are usually on the track to getting a divorce. However, I should note, all real species of animals are valid input, excluding the shortening period added to truncate their name. Some of those will include hyphens, and spaces.

The goal and the rules contradict each other. In order to achieve the goal, the rules would have to allow seven pairs of sacrificial animals such as sheep.

@PeterTaylor the old testament is not canonical anyway.....  haha.

Do you mean "monkey with cymbals"?

@Jordan, no, he has a foam ochothorpe and ampersand that he carries around, and he won't give them up....

Perl, 15 13 bytes
Includes +1 for -n
Input on STDIN (or 1 or more filenames as argument like cat), one animal and gender per line in any consistent notation. Prints a line with 1 for true, an empty line for false
perl -M5.010 -n ark.pl

ark.pl
say!${+lc}++

Python 2, 72 bytes
Takes input as a list of strings of the form "animalname T". The idea is it just uses each string as an identifier and should only print true if the string has not occurred in the list so far.
def f(l):k=map(str.lower,l);print[j not in k[:i]for i,j in enumerate(k)]

Try it here!

Very nice, and elegant entry.

Python, 54 52 50 bytes
def f(s,l={}):x=s.lower();r=x in l;l[x]=1;return r

Test case is at ideone
This borrows this neat idea from @gowrath, but extends it by using the fact that when a function is defined with a default argument that is mutable, like a dictionary, it acts as a memoisation (the object retains state between function calls).
Saved 2 bytes by returning None for truthy ("Y") and 0 for falsey ("N").
Save 2 more by (confusingly) returning False for truthy ("Y") and True for falsey ("N").

Java, 246 218 bytes
Lowered byte count thanks to Kevin!.
Takes STDIN as input, outputs weather or not the animal is allowed to board.
import java.util.*;class B{public static void main(String[]a){List l=new ArrayList();Scanner s=new Scanner(System.in);for(;;){String b=s.nextLine().toLowerCase();l.add(b);System.out.println(l.contains(b)?"n":"y");}}}

You can golf it quite a bit by removing unnecessary spaces. Also, you can remove public before class, change args to a, etc. Also, you should include the imports you use. Here is your code golfed: import java.util.*;class B{public static void main(String[]a){List l=new ArrayList();Scanner s=new Scanner(System.in);for(;;){String b=s.nextLine();if(l.contains(b))b="n";else{l.add(b);b="y";}System.out.println(b);}}} (217 bytes) You might like to read through Tips for golfing in Java. :)

Since you use contains to check if it's in the list or not, it doesn't matter if it's added a second, third, etc. time. So you can just always add it and use a ternary check to directly print it. So it becomes this: import java.util.*;class B{public static void main(String[]a){List l=new ArrayList();Scanner s=new Scanner(System.in);for(;;){String b=s.nextLine();l.add(b);System.out.println(l.contains(b)?"n":"y");}}} (202 bytes)

Hmm btw, you neglected one of your own rules atm ("however, Monkey and monkey are very much the same thing, and so the last critter would be denied.") - you forgot to use .toLowercase() somewhere.

@KevinCruijssen is import *; or import *.*; a valid statement in java golfing? it used to work in java 6....

Groovy 43 Bytes
{s->y=[];s.collect{!y.contains(it)&&y.add(it)}}

Try it here: https://groovyconsole.appspot.com/edit/5147446497771520
It uses a list of tuples as the input:
z = [new Tuple('Monkey',true), new Tuple('Monkey',false), new Tuple('Monkey',true), new Tuple('Bee',true)]

Which results in:
[true, true, false, true]

The add function in groovy always returns true, and in groovy tuples have inherent comparison ability for primitive objects, so the contains actually works well for strings and integers without changing it.
So, basically just check if the list contains it and add it to the list.

If the list already contains it we get (false && N/A)
If it does not we get (True && True) and it is added to the running list.

This is all you really need to accomplish this, if you want to tell me to turn it into a closure or something as well it would probably cap out at approximately 45-50 bytes in Groovy.

It's a code snippet, which is not allowed. You must post a full program or a function.

Perl (35 + 1 for -p) 36
Takes input from STDIN, one animal per line in the form animal T. Where T is anything you want to be used for the gender (e.g. T/F, M/F). You could even have multi-character genders, or more than 2 genders (e.g. male/female/apache helicopter).
Includes all character on the line, so if you're inputting from a file you need a newline after the last animal.
$\=($a{lc()}?N:Y);$a{lc()}=1;$_='';

PowerShell v3+, 33 bytes
$a=@();$args|%{$_-notin$a;$a+=$_}

Takes input as command-line arguments of strings of the form Animal Gender where Gender is (pretty much) any identifier you want. Sets an empty array $a, then loops through the input arguments. Places the Boolean result of the -notin operator on the pipeline, and adds the current element into the $a array. PowerShell by default is case-insensitive when comparing strings, so Monkey f, monkey f, mOnKeY F and other variations will all evaluate as the same.
The resulting Booleans are left on the pipeline, and output via implicit Write-Output happens at program completion.
Example
PS C:\Tools\Scripts\golfing> .\noahs-upgraded-ark.ps1 'Monkey m' 'Monkey f' 'Monkey f' 'Monkey with symbols m' 'monkey m'
True
True
False
True
False

Dyalog APL, 16 bytes
Case sensitive solution:
(⍳⍴)∊(∪⍳⍨)

(⍳⍴) which indices
∊ are member of
⍳⍨ each entry's first occurrence in the list
Unfortunately, case-insensitivity is bulky:
(⍳⍴)∊(∪c⍳c←819⌶)

c←819⌶ assign the lowercase function to c
c⍳c is the same as ⍳⍨c. See explanation above.
TryAPL online! (casing is not supported on TryAPL)

Could you or each character with space (32) to get a mock lowercase mapping ? That seems OK with the restricted set of special characters that ineeds to be supported

@TonHospel or?

Bitwise or of the ASCII codes. A is 0x41, or with space (0x20) and get a (0x61). Some languages allow an or directly on the characters themselves. I have no idea if APL easily supports this

@TonHospel No, APL only adjusts number of bits used to represent numbers (1,8,16,32,64,128) or characters (8,16,32), but you have to be explicit to convert characters to numbers or vice-versa.

14 bytes: ⍳∘⍴∊∘∪(⍳⍨819⌶)

Swift 2.2 169 bytes
I did not accept input from standard in I just passed an array of dictionaries to function x.
Golfed
var a=[String]();let x={(d:[[String:Bool]]) in for r in d{for(s,t)in r{let y=s.lowercaseString+t.description;a.append(y);print(a.indexOf(y)==(a.count-1) ? true:false)}}}

UnGolfed
var a=[String]();
let x={(d:[[String:Bool]]) in
    for r in d{
        for(s,t)in r{
            let y=s.lowercaseString+t.description;
            a.append(y);
            print(a.indexOf(y)==(a.count-1) ? true:false)
        }
    }
}

Input
x([["Monkey":true],["Monkey":false],["monkey":true],["Zebra":true]])

Also just for giggles did a crappy javascript version since I did not see anyone else do a javascript one.
JS (ES6) 125 bytes
Golfed
a=[],i=0,j=0;y=(r)=>{for(;j<r.length;j+=2){var y=r[j].toLowerCase()+r[j+1];a[i]=y;console.log(a.indexOf(y)==i++?true:false)}}a=[],i=0,j=0;y=(r)=>{for(;j<r.length;j+=2){var y=r[j].toLowerCase()+r[j+1];a[i]=y;console.log(a.indexOf(y)==i++?true:false)}}

UnGolfed
a=[],i=0,j=0;
y=(r)=>{
  for(;j<r.length;j+=2){
    var y=r[j].toLowerCase()+r[j+1];
    a[i]=y;
    console.log(a.indexOf(y)==i++?true:false)
  }
}

Input
y(["Monkey", true, "Monkey", false, "monkey",true,"zebra",false])

Jelly, 4 bytes
ŒuŒQ

Try it online!
Each animal in the list (argument) is [species, gender], where gender can either be 1 for male or 0 for female. Output is a list of 0s and 1s, where 0 means "not allowed" and 1 means "allowed". This is a function, and therefore a footer has been added to show the actual result.

Ruby, 50 48 bytes
->a,*s{a.map{|x|x[0].upcase!
(s<<x).count(x)<2}}

Try it online!
A lambda accepting an array of [animal, gender] pairs and returning a boolean array.
-2 bytes: Initialize the list of seen animals as a splat arg
->a,*s{                # s is the list of animals seen so far, initially []
  a.map{ |x|           # x is the current animal
    x[0].upcase!       # Transform x's name in place to uppercase
    (d<<x).count(x)<2  # Add x to s, and return true if s has only 1 instance of x
  }
}