text:
Vertically collapse text
Say I have text like this (each word on one line, with no spaces)
Programming
Puzzles
&
Code
Golf

That makes no sense! It totally defies the laws of physics.
Your challenge is to remedy this impossible situation and collapse the text like so:
P
Prog
&uzz
Coderam
Golflesming

So that there is no empty space underneath any character but the characters retain their vertical order.
The goal is to satisfy the requirements but use the fewest bytes of source code possible.

Also, will it be one word per line, or can there be spaces? If there are spaces, should they collapse down, or can spaces bear weight?

"P Prog &uzz Coderam Golflesming", sounds like there's a new candidate for the site's title..

Someone's going to use Marbelous (https://github.com/marbelous-lang/marbelous.py) ?

I decide to use a physics engine and hold a 0 byte

Can there be trailing spaces in the output?

Pyth, 10 bytes
jb_.T.T_.z

Try it online in the Pyth Compiler/Executor.
Idea
We can achieve the desired output by applying four simple transformations:

Reverse the order of the lines:
Golf
Code
&
Puzzles
Programming

Transpose rows and columns:
GC&PP
oour
ldzo
fezg
lr
ea
sm
m
i
n
g

This top justifies, collapsing the original columns.
Transpose rows and columns:
Golflesming
Coderam
&uzz
Prog
P

Reverse the order of the lines:
P
Prog
&uzz
Coderam
Golflesming

Code
        .z  Read the input as a list of strings, delimited by linefeeds.
       _    Reverse the list.
   .T.T     Transpose the list twice.
  _         Reverse the list.
jb          Join its strings; separate with linefeeds.

Grr, was gonna post exactly this :). Have an upvote instead.

I had plans for posting something similar too... Upvoting too

What happens if you transpose the rows & columns before reversing the order?

@JohnOdom Simply transposing twice will move the characters to the top instead of moving them to the bottom. You can start by transposing, by then you'd have to reverse each row, which would be one byte longer.

Holy FoxPro, this was clever.

Haskell, 62 bytes
import Data.List
p=reverse;o=transpose
f=unlines.p.o.o.p.lines

I'm very mature.

+1 Because I rarely ever see Haskell, and for pooping lines.

Python 2, 104 bytes
l=[]
for x in input().split('\n'):n=len(x);l=[a[:n]+b[n:]for a,b in zip(l+[x],['']+l)]
print'\n'.join(l)

An iterative one-pass algorithm. We go through each line in order, updating the list l of lines to output. The new word effectively pushes from the bottom, shifting all letters above it one space. For example, in the test case
Programming
Puzzles
&
Code
Golf

after we've done up to Code, we have
P
Prog
&uzzram
Codelesming

and then adding Golf results in
P
Prog
&uzz
Coderam
Golflesming

which we can view as the combination of two pieces
P     |
Prog  |
&uzz  |
Code  | ram
Golf  | lesming

where the first piece got shifted up by golf. We perform this shifting with a zip of the output list with the element at the end (left side) and output list precedence by a blank line (right side), cutting off each part at the length of the new element.
It might seem more natural to instead iterate backwards, letting new letters fall from the top, but my attempt at that turned out longer.
For comparison, here's a zip/filter approach, with map(None,*x) used for iziplongest (109 bytes):
f=lambda z:[''.join(filter(None,x))for x in map(None,*z)]
lambda x:'\n'.join(f(f(x.split('\n')[::-1]))[::-1])

CJam, 11 bytes
qN/W%zzW%N*

Try it online in the CJam interpreter.
How it works
The idea in the same as in my Pyth answer.
q           e# Read from STDIN.
 N/         e# Split at linefeeds.
   W%       e# Reverse the resulting array.
     zz     e# Transpose it twice.
       W%   e# Reverse the resulting array.
         N* e# Join its strings; separate with linefeeds.

JavaScript (ES6), 146
(The 2 newlines inside template strings are significant and counted)
The idea of @Dennis implemented in JavaScript. The lengthy S function do the transposition line by line and char by char, leaving the result in the t array.
a=>(S=z=>{for(t=[];z.join``;t.push(w))for(w='',n=z.length;n--;z[n]=z[n].slice(1))w+=z[n][0]||''},S(a.split`
`),S(t.reverse()),t.reverse().join`
`)

Less golfed inside the snippet (try in Firefox)

F=a=>(
  S=z=>{
    for(t=[];z.join``;t.push(w))
      for(w='',n=z.length;n--;z[n]=z[n].slice(1))
        w+=z[n][0]||''
  },
  S(a.split`\n`),
  S(t.reverse()),
  t.reverse().join`\n`
)
#I,#O { margin:0; width: 200px; height:100px; border: 1px solid #ccc }

Input
<textarea id=I>Programming
Puzzles
&
Code
Golf
</textarea>
Output

<button onclick='O.innerHTML=F(I.value)'>go</button>

Reduce a few bytes by replacing S(t.reverse()),t.reverse().join with S(R=t.reverse()),R.join.

@IsmaelMiguel no, S changes t, so t after S is not the same as t before S

R, 223 bytes
function(x){a=apply(do.call(rbind,lapply(p<-strsplit(strsplit(x,"\n")[[1]],""),function(x)c(x,rep(" ",max(lengths(p))-length(x))))),2,function(x)c(x[x==" "],x[x!=" "]));for(i in 1:nrow(a))cat(a[i,][a[i,]!=" "],"\n",sep="")}

This is an absurdly long, naïve way of doing it.
Ungolfed:
f <- function(x) {
    # Start by spliting the input into a vector on newlines
    s <- strsplit(x, "\n")[[1]]

    # Create a list consisting of each element of the vector
    # split into a vector of single characters
    p <- strsplit(s, "")

    # Pad each vector in p to the same length with spaces
    p <- lapply(p, function(x) c(x, rep(" ", max(lengths(p)) - length(x))))

    # Now that the list has nice dimensions, turn it into a matrix
    d <- do.call(rbind, p)

    # Move the spaces to the top in each column of d
    a <- apply(d, 2, function(x) c(x[x == " "], x[x != " "]))

    # Print each row, omitting trailing whitespace
    for (i in 1:nrow(a)) {
        cat(a[i, ][a[i, ] != " "], "\n", sep = "")
    }
}

You can try it online.

Matlab / Octave, 99 bytes
function f(s)
c=char(strsplit(s,[10 '']));[~,i]=sort(c>32);[m,n]=size(c);c(i+repmat((0:n-1)*m,m,1))

Example:
Define an input string in a variable, say s. 10 is the line feed character:
>> s = ['Programming' 10 'Puzzles' 10 '&' 10 'Code' 10 'Golf'];

Call function f with input s:
>> f(s)
ans =
P
Prog
&uzz
Coderam
Golflesming

Or try it online (thanks to @beaker for help with the online Octave interpreter)

JavaScript ES6, 119 bytes
F=s=>(C=o=>--a.length?C(a.reduce((p,c,i)=>c+p.slice((a[i-1]=p.slice(0,c.length)).length)))+`
`+o:o)(a=(s+`
`).split`
`)

Here it is ungolfed and in ES5 with comments explaining how it works:

function F(s) {
  var arr = (s+'\n').split('\n'); // Create an array of words and append an empty member
  return (function C(output) {
    return --arr.length ? // Remove the last item from the array
      C(arr.reduce(function(p,c,i) { // If the array still has length reduce it to a string and recurse
        var intersection = (arr[i-1] = p.slice(0, c.length)) // Overwrite the previous word with the part that intersects the current word
        return c + p.slice(intersection.length) // Add the part of the previous word that doesn't intersect to the current value
      })) + '\n' + output : output // Add the last level of recursions output on to the end of this
  })(arr);
}

input.addEventListener('input', updateOutput, false);

function updateOutput() {
  var oldLength = input.value.length;
  var start = this.selectionStart;
  var end = this.selectionEnd;
  input.value = input.value.split(/ +/).join('\n');
  var newLength = input.value.length;
  input.setSelectionRange(start, end + (newLength - oldLength));
  output.value = F(input.value).trim();
}

updateOutput();
textarea {
  width: 50%;
  box-sizing: border-box;
  resize: none;
  float: left;
  height: 10em;
}

label {
  width: 50%;
  float: left;
}

Type in the input box below, spaces are automatically converted to newlines and the output updates as you type

Input
Output
<textarea id="input">
Type inside me :)
</textarea>
<textarea id="output" disabled>
</textarea>

APL (Dyalog Extended), 13 11 bytesSBCS
-2 with my extensions to Dyalog APL.
Anonymous tacit function, taking and returning a character matrix.
~∘' '⍤1⍢⍉⍢⊖

Try it online!
~ remove
∘ the
' ' spaces
⍤ from
1 rows (lit. 1D sub-arrays)
⍢ while
⍉ transposed
⍢ while
⊖ flipped

wait how is this 33 bytes?

STATA, 323 bytes
Takes input in a file called a.b
Only works for up to 24 characters now. Will update later to make it work with more. Also, doesn't work in the online compiler. Requires the non-free compiler.
gl l=24/
forv x=1/$l{
gl a="$a str a`x' `x'"
}
infix $a using a.b
gl b=_N
forv k=1/$l{
gen b`k'=0
qui forv i=$b(-1)1{
forv j=`i'/$b{
replace b`k'=1 if _n==`j'&a`k'==""
replace a`k'=a`k'[_n-1] if _n==`j'&a`k'==""
replace a`k'="" if _n==`j'-1&b`k'[_n+1]==1
replace b`k'=0
}
}
}
forv i=1/$b{
forv k=1/$l{
di a`k'[`i'] _c
}
di
}

Edit: moved the quietly (to suppress output) to the loop itself from each statement in the loop, saving 8 bytes.

Why would your submission be invalid, just because it requires a non-free compiler?

@Dennis I thought that was decided in meta that programming languages must be runnable in some free environment. Also, the restrictions on input length might invalidate it.

The character restriction would be a problem, but I'm not aware of any meta consensus that requires a free implementation. (If you got this idea from the Hello World quiz, that question explicitly asked for free languages.)

@Dennis I figured this was a consensus: http://meta.codegolf.stackexchange.com/questions/988/untestable-languages

The answer suggests downvoting untestable posts, which doesn't really require consensus, and doesn't happen in practice. In fact, Mathematica and TI-BASIC answers are usually quite popular.

R, 190 178 175 Bytes
Probably still some room for golfing in this.  Probably a couple of unnecessary operations in there
l=lapply;s=substring;C=rbind;d=do.call;cat(C(d(C,l(apply(d(C,l(a<-scan(,''),s,1:(w=max(nchar(a))),1:w))[(h=length(a)):1,],2,paste0,collapse=''),s,1:h,1:h))[,h:1],'\n'),sep='')

Ungolfed and explained
a<-scan(,'')    # get STDIN
h<-length(a)    # number of lines
w=max(nchar(a)) # length of longest line
M<-lapply(a,substring,1:w,1:w)   # create a list of split strings with empty chars
M<-do.call(rbind,M)[h:1,]        # turn it into a matrix with line order reversed
M<-apply(M,1,paste0,collapse='') # paste together the columns
M<-lapply(M,substring,1:h,1:h)   # split them back up
M<-do.call(rbind,M)[,h:1]        # reform a matrix
M<-rbind(M,'\n')                 # add some carriage returns
cat(M,sep='')   # output with seperators

Test Run.  It is interesting to note that due to the way that scan works, the whole sentence can be input with spaces and still give the output as specified.
> l=lapply;s=substring;C=rbind;d=do.call;cat(C(d(C,l(apply(d(C,l(a<-scan(,''),s,1:(w=max(nchar(a))),1:w))[(h=length(a)):1,],2,paste0,collapse=''),s,1:h,1:h))[,h:1],'\n'),sep='')
1: Programming
2: Puzzles
3: &
4:     Code
5: Golf
6:
Read 5 items
P
Prog
&uzz
Coderam
Golflesming
> l=lapply;s=substring;C=rbind;d=do.call;cat(C(d(C,l(apply(d(C,l(a<-scan(,''),s,1:(w=max(nchar(a))),1:w))[(h=length(a)):1,],2,paste0,collapse=''),s,1:h,1:h))[,h:1],'\n'),sep='')
1: Programming Puzzles & Code Golf beta
7:
Read 6 items
P
Prog
&uzz
Code
Golfram
betalesming
>

R, 171 bytes
S=scan(,"");while(any((D<-diff(N<-sapply(S,nchar)))<0)){n=max(which(D<0));S[n+1]=paste0(S[n+1],substr(S[n],N[n]+D[n]+1,N[n]));S[n]=substr(S[n],1,N[n]+D[n])};cat(S,sep="\n")

With newlines and indentation:
S=scan(,"") #Takes input from stdin
while(any((D<-diff(N<-sapply(S,nchar)))<0)){
    n=max(which(D<0))
    S[n+1]=paste0(S[n+1],substr(S[n],N[n]+D[n]+1,N[n]))
    S[n]=substr(S[n],1,N[n]+D[n])
}
cat(S,sep="\n")

Usage:
> S=scan(,"");while(any((D<-diff(N<-sapply(S,nchar)))<0)){n=max(which(D<0));S[n+1]=paste0(S[n+1],substr(S[n],N[n]+D[n]+1,N[n]));S[n]=substr(S[n],1,N[n]+D[n])};cat(S,sep="\n")
1: Programming
2: Puzzles
3: &
4: Code
5: Golf
6:
Read 5 items
P
Prog
&uzz
Coderam
Golflesming

Jelly, 6 bytes (non-competing)
ỴṚZZṚY

Try it online!
How it works
The idea in the same as in my Pyth answer.
ỴṚZZṚY  Main link. Argument: s (string)

Ỵ       Split at linefeeds.
 Ṛ      Reverse the order of the lines.
  ZZ    Zip/transpose twice.
    Ṛ   Reverse the order of the lines.
     Y  Join, separating by linefeeds.

Turtlèd, 72 bytes, noncompeting
Fairly sure I could change approach to save bytes, but later.
:p Non-golf esolang beats regular langs :p
The odd thing about Turtlèd is it was originally made after discussion about ascii art langs, but it actually seems to be best at these kinds of challenges
Turtlèd can not take newline input but for multiple inputs, and this takes only one input: terminate each word with a space, including the last one.
!l[*,+r_][ l]ur[*,[ -.]+.[ r{ d}u+.]-.[ -.]{ l}[ l]r[ u]_]' d[ d]u[ ' r]

Try it online!
Explanation:
!                          Take string input
 l                         Move left, off the asterisk at the start of grid
  [*    ]                  Until cell is *
    ,+r_       write *, string pointer+=1, move right, write * if pointed char is last char
         [ l]ur    move left until finding a space, move up and right
               [*                                        ]     Until cell is *
                 ,                               write *
                  [   ]             until cell is [space]
                    -.               decrement string pointer, write pointed char
                       +.           increment and write string pointer
                         [         ] until cell is [space]
                           r{ d}     move right, move down until finding nonspace
                                u+.  move up, string pointer+=1 and write pointed char
                                    -.      decrement string pointer and write pointed char
                                      [   ]  until cell is [space]
                                        -.  string pointer-=1 and write pointed char
                                           { l}   move left until finding nonspace
                                               [ l]   move left until finding space
                                                   r   move right
                                                    [ u]  move up until finding space
                                                        _  write * if pointed char is last char
                                                          (if it is written, loop ends)

                                                          ' d[ d]u[ ' r] just cleanup

Perl, 133 bytes
This was one of those challenges that changed in my head from being too hard, to being easy, to being a lot more code than I'd anticipated... I'm not particularly happy with the approach, I'm sure there's a much better way to reduce the print pop@F... bit perhaps using -n or just pure regex, but I can't get there right now... Originally I was using say, but I think I'd have to score that higher (use 5.01) because of $'.
@F=(/.+/g,@F)for<>;$_%=$#F,($x=length$F[$_++])<length$F[$_]&&($F[$_]=~/.{$x}/,$F[$_-1].=$',$F[$_]=$&)for 0..1e2;print pop@F,$/while@F

Usage
Save as vertically-collapse-text.pl.
perl vertically-collapse-text.pl <<< 'Programming
Puzzles
&
Code
Golf'
P
Prog
&uzz
Coderam
Golflesming

SmileBASIC, 90 bytes
X=RND(50)Y=RND(20)G=CHKCHR(X,Y+1)<33LOCATE X,Y+G?CHR$(CHKCHR(X,Y));
LOCATE X,Y?" "*G
EXEC.

Applies gravity to all text in the console. I'm not sure if this is valid, or if I have to use a string array.

Ruby, 99 82 bytes
Getting there...
f=->a,i=-1{a.map{|l|i+=1;(0...l.size).map{|c|a.map{|x|x[c]}.join[~i]}*''}.reverse}

An attempted explanation:
f=->a,i=-1{a.map{|l|i+=1; # For each line `l` with index `i` in string array `a`
(0...l.size).map{|c|        # For each column `c` in `l`
a.map{|x|x[c]}.join           # Make a string of non-nil characters `c` across `a`...
[~i]                          # ...and grap the `i`th character *from the end*, if any
}*''}.reverse}              # Join the characters grabbed from each column and reverse the result

Run it like this:
a = %w[
  Programming
  Puzzles
  &
  Code
  Golf
]
puts f[a]

K, 30
{+{(-#x)$x@&~^x}'+x@\:!|/#:'x}

.
k){+{(-#x)$x@&~^x}'+x@\:!|/#:'x}("Programming";"Puzzles";,"&";"Code";"Golf")
"P          "
"Prog       "
"&uzz       "
"Coderam    "
"Golflesming"

Explanation
x@\:!|/#:'x extends each string to create a square char matrix.
k){x@\:!|/#:'x}("Programming";"Puzzles";,"&";"Code";"Golf")
"Programming"
"Puzzles    "
"&          "
"Code       "
"Golf       "

+ transposes it
k){+x@\:!|/#:'x}("Programming";"Puzzles";,"&";"Code";"Golf")
"PP&CG"
"ru oo"
"oz dl"
"gz ef"
"rl   "
"ae   "
"ms   "
"m    "
"i    "
"n    "
"g    "

{(-#x)$x@&~^x} will remove any spaces from a string and then pad the string by its original length
k){(-#x)$x@&~^x}"a  b  c   de  f"
"         abcdef"

Apply that function to each of the transposed strings, then flip the output to get the result
k){+{(-#x)$x@&~^x}'+x@\:!|/#:'x}("Programming";"Puzzles";,"&";"Code";"Golf")
"P          "
"Prog       "
"&uzz       "
"Coderam    "
"Golflesming"

{+{(-#x)$x@&~^x}'+(|/#:'x)$x} for 29.

pb - 310 bytes
^w[B!0]{w[B=32]{vb[1]^b[0]}>}b[1]vb[1]>b[2]<[X]w[B!2]{t[T+B]b[0]>}b[0]v[T]w[X!-1]{b[1]<}b[1]vb[1]w[B!0]{w[B!0]{^w[B!0]{>}<<<<^[Y+1]w[B!0]{<}>t[B]b[0]w[B!1]{v}v<[X]w[B!0]{>}b[T]}b[0]vb[1]^w[X!0]{<vb[1]^t[B]b[0]^w[B!0]{^}b[T]w[B!0]{v}}vw[B!0]{^^w[B!0]{>}<b[0]vvw[B=0]{<}b[0]<[X]}^^>w[B=0]{vb[1]}v<<}>>^b[0]^<b[0]

What a disaster. I barely remember anything about how it works.
Because of the way pb's input works (a single line all at once), you have to use spaces instead of newlines in the input. If the interpreter wasn't garbage and you could include newlines in the input, the only change would be the [B=32] at the beginning becoming [B=10].
I'm working on an update to pbi (the interpreter) that will clean up the visuals if you want to watch the program run. It still needs a lot of work but in the mean time, you can watch this program on YouTube.

J, 17 bytes
-.&' '"1&.(|:@|.)

Quite pleasant solution.
Explanation:
-.&' '"1&.(|:@|.)  input: list of strings y
              |.   reverse lines
           |:@     then transpose
-.&' '"1           remove blanks from columns
        &.         and undo the inside
           |:@|.   (that is, transpose and reverse again.)

Test case explained
   s
Programming
Puzzles
&
Code
Golf
   |.s
Golf
Code
&
Puzzles
Programming
   |:|.s
GC&PP
oo ur
ld zo
fe zg
   lr
   ea
   sm
    m
    i
    n
    g
   -.&' '"1|:|.s
GC&PP
oour
ldzo
fezg
lr
ea
sm
m
i
n
g
   |.-.&' '"1|:|.s
g
n
i
m
sm
ea
lr
fezg
ldzo
oour
GC&PP
   |.|:-.&' '"1|:|.s
P
Prog
&uzz
Coderam
Golflesming
   (-.&' '"1)&.(|:@|.)s
P
Prog
&uzz
Coderam
Golflesming
   -.&' '"1&.(|:@|.)s
P
Prog
&uzz
Coderam
Golflesming

Test cases
   f =: -.&' '"1&.(|:@|.)
   f
-.&' '"1&.(|:@|.)
   f >'Programming';'Puzzles';'&';'Code';'Golf'
P
Prog
&uzz
Coderam
Golflesming
   g =: [: > [: <;._1 '|'&,
   g 'Programming|Puzzles|&|Code|Golf'
Programming
Puzzles
&
Code
Golf
   f g 'Programming|Puzzles|&|Code|Golf'
P
Prog
&uzz
Coderam
Golflesming
   F =: f @ g
   F &. > 'Programming|Puzzles|&|Code|Golf' ; '1|23|456|7890' ; '1234|567|89|0'
+-----------+----+----+
|P          |1   |1   |
|Prog       |23  |52  |
|&uzz       |456 |863 |
|Coderam    |7890|0974|
|Golflesming|    |    |
+-----------+----+----+

;@;:&.(|:@|.) for 13

Racket 312 bytes
(let((lr list-ref)(ls list-set)(sl string-length)(ss substring)(l(string-split s)))(let p((ch #f))
(for((i(-(length l)1)))(define s(lr l i))(define r(lr l(+ 1 i)))(define n(sl s))(define m(sl r))
(when(> n m)(set! l(ls l i(ss s 0 m)))(set! l(ls l(+ 1 i)(string-append r(ss s m n))))(set! ch #t)))(if ch(p #f)l)))

Ungolfed:
(define (f s)
  (let ((lr list-ref)
        (ls list-set)
        (sl string-length)
        (ss substring)
        (l (string-split s)))
    (let loop ((changed #f))
      (for ((i (sub1 (length l))))
        (define s (lr l i))
        (define r (lr l (add1 i)))
        (define n (sl s))
        (define m (sl r))
        (when (> n m)
          (set! l (ls l i (ss s 0 m)))
          (set! l (ls l (add1 i)(string-append r (ss s m n))))
          (set! changed #t)))
      (if changed (loop #f)
          l))))

Testing:
(f "Programming Puzzles & Code Golf")

Output:
'("P" "Prog" "&uzz" "Coderam" "Golflesming")

Actually, 13 bytes
This uses the algorithm described in Dennis' Jelly answer. Input and output are both lists of strings. Unfortunately, the builtin transpose function does not work very well if the inner lists or strings aren't all the same length, which would kind of defeat the point of vertically collapsing in the first place. Golfing suggestions welcome. Try it online!
R2`;i(lZ♂Σ`nR

Ungolfing
          Implicit input s.
R         Reverse s.
2`...`n   Run the following function twice.
  ;i        Duplicate and flatten onto the stack.
  (l        Get the number of strings in the list.
  Z         Zip len strings together, which results in a list of lists of characters.
  ♂Σ        Sum each list of characters, which essentially joins them together.
           This function essentially transposes
R         Reverse the result.
          Implicit return.

JavaScript (ES6), 103 bytes
v=>(v=v.split`
`).map(_=>v=v.map((x,i)=>v[++i]?x.slice(0,n=v[i].length,v[i]+=x.slice(n)):x))&&v.join`
`

Split on CR, outer map ensures we loop enough times to allow "gravity" to drop letters as far as they need to drop.
Inner map first checks if there is a next line, if so, and it is shorter, drop the overflow to the next line.  i.e if the 1st line has "ABCD" and the 2nd line has "FG", drop the "CD" from 1st line to the 2nd so that the 1st line becomes "AB" and the 2nd becomes "FGCD".
As we do this as many times as there are lines, the letters drop as far as they should, leaving us with the desired outcome.

Japt, 8 bytes
y kS ù y

Try it online!
How it works
Uy kS ù y

Uy  Transpose at newline
kS  Replace spaces with nothing
ù   Left-pad to fit the longest line
y   Transpose at newline

There's also z which rotates the 2D string by a multiple of 90 degrees, but it somehow truncates the string when height > length.

7 bytes. Welcome to Japt, by the way (if I haven't welcomed you already).

R, s81 52 bytes
function(x)apply(x,2,function(.).[order(!is.na(.))])

#old,longer version did the same but less efficiently
#function(x)apply(x,2,function(x){n<-na.omit(x);c(rep("",length(x)-length(n)),n)}))

I took some liberty in interpreting the question and presumed that the text is represented in a matrix with one character per cell, thus:
x <- as.matrix(read.fwf(textConnection("Programming
Puzzles
&
Code
Golf"), widths=rep(1, 11)))

So x becomes:
     V1  V2  V3  V4  V5  V6  V7  V8  V9  V10 V11
[1,] "P" "r" "o" "g" "r" "a" "m" "m" "i" "n" "g"
[2,] "P" "u" "z" "z" "l" "e" "s" NA  NA  NA  NA
[3,] "&" NA  NA  NA  NA  NA  NA  NA  NA  NA  NA
[4,] "C" "o" "d" "e" NA  NA  NA  NA  NA  NA  NA
[5,] "G" "o" "l" "f" NA  NA  NA  NA  NA  NA  NA

Now I use order and [ to sort the columns so that the NA's come first and then all other values:
     V1  V2  V3  V4  V5  V6  V7  V8  V9  V10 V11
[1,] "P" NA  NA  NA  NA  NA  NA  NA  NA  NA  NA
[2,] "P" "r" "o" "g" NA  NA  NA  NA  NA  NA  NA
[3,] "&" "u" "z" "z" NA  NA  NA  NA  NA  NA  NA
[4,] "C" "o" "d" "e" "r" "a" "m" NA  NA  NA  NA
[5,] "G" "o" "l" "f" "l" "e" "s" "m" "i" "n" "g"

It becomes longer if it is required that the output be words:
s <- (function(x)apply(x,2,function(.).[order(!is.na(.))]))(x)
s[is.na(s)]<-""
apply(s, 1, paste, collapse="")
# [1] "P"           "Prog"        "&uzz"        "Coderam"     "Golflesming"

Welcome (back) to PPCG! As long as OP is fine with your format, you're safe! the usual way is to ask it in a comment to the question.

as mentioned in your answer to another question, answers need to be full fuinctions or programs so function(x) need to be included in the byte count.

05AB1E, 10 9 bytes
¶¡RζðмζR»

Try it online.
or with alternative start:
.BRøðмζR»

Try it online.
Similar approach as @Dennis♦' Pyth answer.
-1 byte thanks to @Emigna replacing ðõ: with ðм.
Explanation:
¶¡       # Split on new-lines
  R      # Reverse the list
   ζ     # Zip/Transpose with unequal-length items (with space filler by default)
ðм       # Remove all spaces
  ζ      # Zip/Transpose unequal-length items (with space filler) again
   R     # Reverse the list again
    »    # Join the list by newlines, and output implicitly

Alternative explanation:
.B      # Box (implicitly splits on new-lines and appends spaces)
   ø    # Zip/Transpose with equal-length items
        # Rest is the same

R, 196 189 170 bytes
function(x){l=nchar;o=function(y)which(diff(l(y))<0)[1];d=function(x,i)"[<-"(x,i:(j<-i+1),c(a<-substr(x[i],1,l(x[j])),sub(a,x[j],x[i])));while(!is.na(o(x)))x=d(x,o(x));x}

A human-readable version:
f<-function(x){
  l=nchar;

  # find the first line in x that is longer than the next line
  # if no such line exists o(x) will be NA
  o = function(y) which(diff(l(y))<0)[1]

  # d(x,i) --> clips the line i in x, adding the remainder to x[i+1]
  d = function(x,i) "[<-"(x,i:(j<-i+1),
        c(a<-substr(x[i],1,l(x[j])), sub(a,x[j],x[i])))
         # a --> clipped x[i],      sub(a,x[j],x[i]) --> expanded x[j]

  while(!is.na(o(x)))x=d(x,o(x));x
}

How it works:

Take the first "bad" line, i.e., line which is longer than the next line, take the "extra" part and add it to the next line
Check if there are any "bad" lines left, if yes go to #1

(Or in other words, "superfluous" parts fall down until everything that can fall down has fallen down.)
Input: a character vector.
x<-readLines(textConnection("Programming\nPuzzles\n&\nCode\nGolf"))
f(x)
# [1] "P"           "Prog"        "&uzz"        "Coderam"     "Golflesming"

Vyxal, 6 bytes
□Ṙ∩∩Ṙ⁋

Try it Online!
Uses the same idea as Pyth answer
Explanation:
□      Input as a list separated by newlines
 Ṙ     Reverse
  ∩    Transpose rows and columns
   ∩   Same as above
    Ṙ  Reverse
     ⁋ Join by newlines
Implicit output the result

Julia 0.6, 141 bytes
l=length
g(z,i)=(n=z[i];m=z[i+1];(N,M)=l.([n,m]);z[i:i+1]=[n[1:min(N,M)],m*n[M+1:N]])
f(s,w=split(s),d=1:l(w)-1)=(g.([w],[d d]);join(w,"\n"))

Try it online!
Broadcasting with g.([w], [d d]) allows me to get rid of any map statement and saves me around 7 bytes.

all_licenses: 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/


text:
Sort a list of numbers on the λ-calculus
Write a term on the pure untyped lambda calculus that, when applied to a church-encoded list of numbers, returns it with its numbers sorted in ascending or descending order. Church lists and numbers must be encoded as folds for their usual ADTs:
-- Usual ADTs for Lists and Nats (in Haskell, for example)
data List a = Cons a (List a) | Nil
data Nat a  = Succ (Nat a) | Zero

-- Their respective folds are the λ-calculus representation used on this challenge
church_list = (λ c n . (c ... (c ... (c ... n))))
church_num  = (λ succ zero . (succ (succ (succ ... zero))))

Example input:
(λ cons nil .
    (cons (λ f x . (f x))                         -- 1
    (cons (λ f x . (f (f (f (f (f (f (f x)))))))) -- 7
    (cons (λ f x . (f (f x)))                     -- 2
    (cons (λ f x . (f (f (f x))))                 -- 3
    nil)))))

Example output:
(λ cons nil .
    (cons (λ f x . (f x))                         -- 1
    (cons (λ f x . (f (f x)))                     -- 2
    (cons (λ f x . (f (f (f x))))                 -- 3
    (cons (λ f x . (f (f (f (f (f (f (f x)))))))) -- 7
    nil)))))

The score of a submission will be calculated as follows:
score(x)    = 1
score(λx.t) = score(t) + 1
score(t s)  = score(t) + score(s) + 1

Lowest score wins.

The linked page provides three different Church encodings for lists, and there's nothing to stop it from changing in the future. In order that the question be unambiguous, you will need to define the particular encoding you have in mind explicitly in the question. (It would also be advisable to define the encoding of the numbers).

ascending or descending order -- why do we get to pick?

I just didn't find a reason to limit it. Why not?

I've managed to beat my own mark:
sort = λabcd.a(λef.f(λghi.g(λj.h(λkl.kj(ikl)))(hi))e(λgh.h))
       (λe.d)(λe.b(λf.e(f(λghi.hg)(λgh.cfh))))

There is a caveat, though - this term must receive an additional argument with the maximum size of naturals that are considered. For example, sort 4 [1,7,3,6,5] will return [1,3], ignoring anything above or equal 4. Of course, you could just give infinity (i.e., the Y-combinator):
sort = λbcd.(λfx.f(x x))(λfx.f(x x))(λef.f(λghi.g(λj.h(λkl.kj(ikl)))
       (hi))e(λgh.h))(λe.d)(λe.b(λf.e(f(λghi.hg)(λgh.cfh))))

And it would sort any list of natural numbers, but this term obviously doesn't have a normal form anymore.

121 characters / score 91
sort = λabc.a(λdefg.f(d(λhij.j(λkl.k(λmn.mhi)l)(h(λkl.l)i))
       (λhi.i(λjk.bd(jhk))(bd(h(λjk.j(λlm.m)k)c))))e)(λde.e)
       (λde.d(λfg.g)e)c

It is in normal form and could be made shorter by lifting common subexpressions.

Here's an implementation of an insertion sort:
let nil =       \f x.x in
let cons = \h t.\f x.f h (t f x) in
let 0 =       \f x.x in
let succ = \n.\f x.f (n f x) in
let None =    \a b.b in
let Some = \x.\a b.a x in
let pred = \n.n (\opt.opt (\m.Some(succ m)) (Some 0)) None in
let optpred = \opt.opt pred None in
let - = \m n.n optpred (Some m) in
let < = \m n.\trueval falseval.- m n (\diff.falseval) trueval in
let pair = \x y.\f.f x y in
let snd = \p.p (\x y.y) in
let insert = \n l.snd (l (\h recpair.recpair (\rawtail insertedtail.
  let rawlist = cons h rawtail in
    pair rawlist (< h n (cons h insertedtail) (cons n rawlist))))
  (pair nil (cons n nil))) in
\l.l insert nil

Here, pred n returns an element of option nat: pred 0 is None whereas pred (n+1) is Some n.  Then, - m n returns an element of option nat which is Some (m-n) if m>=n or None if m<n; and < m n returns a boolean.  Finally, insert uses an internal function returning a pair where f l = (l, insert n l) (a fairly typical method to get the tail of the list to get passed to the recursion along with the recursive value).
Now, some notes for future golfing work: actually nil, 0, None happen to be the same function formally (and it also appears in snd).  Then, I would certainly consider doing beta reductions on the let statements (which is of course the usual syntactic sugar where let a = x in y means (\a.y)x and thus has score score(x) + score(y) + 2) to see in which cases doing so would reduce the score - which it most definitely would for the bindings that are only used once.
Then would come trickier things: for example, I just noticed that formally pred = pair (pair (\m.Some(succ m)) (Some 0)) None, optpred = pair pred None, - = \m.pair optpred (Some m), the sort function definition amounts to pair insert nil, etc. which could reduce the score slightly.

Please calculate your score and state it in the answer

source: Stack Exchange

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

sort: votes


text:
Up 12 at 4 it's
Introduction
On BBC Radio 2, on Saturdays there's a show hosted by Tony Blackburn called Pick of the Pops. Here, Tony selects a random week from a random year (in the range 1960-1989), and plays the songs which were in the top 20 charts at the time.
Challenge
Given a list of songs played on one Pick of the Pops episode, you must determine the year which Tony has chosen.
Further Information
Input
The input will be given as a string (either by STDIN or function arguments), with each list item separated by a comma.
The input will sorted with the number one single first, carrying on in order until the list ends with the number 20 single.
On the actual show, Blackburn plays the charts for two different years. This will not be the case for your input, only the chart for your one year will be supplied.
If song usually has a comma in its name, then the comma will be omitted.
Output
Your output should simply be the year in the format YYYY (1989, 2365, 1901).
If for any reason, multiple years are found (say if the charts are form the first week of the year), then either select the first year or output both, comma separated.
Rules
You can read from either a file or the internet.
If you use the internet, you must only use pages on the website officialcharts.com.
Note: if you read from a Wikipedia page, the page must have been created before the 23rd of August 2015.
The charts will be from the national UK charts, not international or of any other country.
Your output must be in the range of 1960 - 1989.
Examples
Input
Ticket to Ride,Here Comes the Night,The Minute You're Gone,Concrete and Clay,Little Things,Catch the Wind,For Your Love,King of the Road,The Last Time,Pop Go the Workers,Bring It On Home to Me,Stop in the Name of Love,Times They Are A-Changin',You're Breakin' My Heart,I Can't Explain,I'll Be There,Everybody's Gonna Be Happy,It's Not Usual,A World of Our Own,True Love Ways

Output

1965

Winning
The person with the shortest program in bytes wins.
Note
At the moment, I'm still downloading all of the chart information, but you can use the following Python 2 code to retrieve the necessary information and create the file. (Requires the requests module)
import requests, re, datetime, time

date = datetime.date(1960,1,1)
prevyear=0
year = 1960

delay = # Set the delay yourself. So far 4 seconds still makes the download fail

while date.year != 1990:

    response = requests.get("http://www.officialcharts.com/charts/singles-chart/%d%02d%02d"%(date.year, date.month, date.day)).text
    time.sleep(delay)

    tags = re.findall(".+", response)[:20]
    top20s = []

    for i in tags[:]:
        tag = re.sub("", "", i)
        tag = re.sub("","",tag)
        top20s.append(tag)

    top20s = list(map(lambda x:x.replace(",",""), top20s))

    with open("songs.txt", "a") as f:
        if year != prevyear:
            string = str(year)+"\n"
        else:
            string = ""

        chart = ",".join(top20s)

        f.write(string+chart+"\n")

    prevyear = year
    date += datetime.timedelta(days=7)
    year = date.year

I'd suggest that you compile the information into one file, which would then be the only ressource everoyne can use.

@flawr I'll start work on making the file

What to do about songs with commas in the title? Such as Walk, Don't Run by the Ventures (1960).

@Geobits The comma will be removed

The grammar in the title is like sandpaper against my brain.

Info for those considering using the Wikipedia API: https://www.mediawiki.org/wiki/API:Main_page

@AlexA. I'm only quoting Tony Blackburn ;)

Obligatory HTML w/ regex comment.

@NoOneIsHere I don't know how, but I managed to survive after opening Pandora's Box

By the way, your username should be (for Greek accuracy) βήτα διάσπαση.

@BetaDecay Did chart information finish downloading? xD A single data file would make this challenge more accessible.

How large is this file? Is it still downloading after ~2.5 years?

@EriktheOutgolfer It's been over four years and it still hasn't downloaded

C# (277, 271,  223 compacted  bytes)
After six years, this deserves an answer, so I'm going to make some assumptions:

The data is stored in the file: C:\songs.txt.
The songs for each week are stored on a new line in the following format:

yyyy:song,song,song,...

var @in = Console.ReadLine();
var d = File.ReadAllText(@"C:\songs.txt");
foreach (var w in d.Split('\n')) {
    var wd = w.Split(':');
    if (wd[1].Split(',').Any(a => @in.Split(',').ToList().Any(i => i.Equals(a)))) {
        Console.Write(wd[0]);
        break;
    }
}

Note: Compacted in this case means removing all line breaks and unnecessary whitespace. I'm retaining proper formatting for the sake of readability.

TIO


text:
Number of domino tilings
Write a program or function that given positive n and m calculates the number of valid distinct domino tilings you can fit in a n by m rectangle. This is sequence A099390 in the Online Encyclopedia of Integer Sequences. You may take input in as function argument(s), CLA or on stdin, in any reasonable format. You must return or print a single integer as output.
Each tiling must not leave any gaps, and every distinct tiling is counted, including rotations, reflections, etc. For example, the tilings for 2x3 are:
|--    |||    --|
|--    |||    --|

Example inputs/outputs:
1,  9 -> 0
2,  2 -> 2
2,  3 -> 3
4,  4 -> 36
4,  6 -> 281
6,  6 -> 6728
7, 10 -> 53175517

Your program should theoretically work for any n and m, but if your program requires too much memory or your data type overflows it's excused. Your program must work correctly for any n, m <= 8 however.

Shortest code in  bytes wins.

You could have made our life much easier if you only had allowed 2n x 2m areas, nice challenge!

Just like this question http://codegolf.stackexchange.com/q/51067/15599 only shorter, and slower

@edc65 Damnit =/ I can't seem to think of anything novel... Almost every challenge I think of has already been done in some form. Either way, the challenges are not exactly the same since my question is a code golf, and you don't have to find the tilings - only the amount of them. Maybe people can use nice formulas instead of writing a bruteforcer.

Agreed - going to remove the other comment

Copied bilbo's comment (which he posted as an answer due to 1 rep): "This problem is a SPOJ challenge shorten: http://www.spoj.com/problems/MNTILE/ The shortest code on SPOJ is 98 bytes in awk.". Seems like I'm doubly unoriginal - I was unaware.

@flawr, the fully general solution isn't much more complicated than that (and in some senses it's less complicated). The tricky thing is dealing with numerical issues in a way that's provably correct.

Incidentally, as a dimer tiling question, this is very closely related to http://codegolf.stackexchange.com/q/51266/194

Pyth, 30 29 bytes
L?bsmy-tb]dfq1.a-VThbb1y*FUMQ

Try it online: Demonstration / Test Suite
All example inputs run in the online compiler. The last one takes a few seconds though.
Explanation:
In my code I'll define a recursive function y. The function y takes a list of 2D-coordinates and returns the number of different domino tilings using these coordinates. E.g. y([[0,0], [0,1]]) = 1 (one horizontal domino), y([[0,0], [1,1]]) = 0 (coordinates are not adjacent) and y([[0,0], [0,1], [1,0], [1,1]]) = 2 (either two horizontal or two vertical dominoes). After defining the function I'll call it with all coordinates [x,y] with x in [0, 1, m-1], y in [0, 1, n-1].
How does the recursive function work? It's quite simple. If the list of coords is empty, there is exactly one valid tiling and y returns 1.
Otherwise I take the first coordinate in the list b[0], and search the remaining coordinates for a neighbors. If there is no neighbor to b[0], then there is no tiling possible, therefore I return 0. If there is one or more neighbors, then the number of tilings is (the number of tilings where I connect b[0] with the first neighbor via a domina, plus the number of tilings where I connect b[0] with the second neighbor, plus ...) So I call the function recursively for each neighbor with the shortened list (by removing the two coords b[0] and neighbor). Afterwards I sum up all results and return them.
Because of the order of the coords there are always only two neighbors possible, the one on the right side and the one below. But my algorithm doesn't care about that.
                          UMQ  convert the input numbers into ranges
                        *F     Cartesian product (coords of each square)
L                              define a function y(b):
 ?b                              if len(b) > 0:
           f         b             filter b for squares T, which satisfy:
              .a-VThb                Euclidean distance between T and b[0]
            q1                       is equal to 1 (direct neighbors)
    m                              map each neighbor d to:
      -tb]d                          remove d from b[1]
     y                               and call recursively y with the rest
   s                               sum all those values and return them
                                 else:
                      1            return 1 (valid domino tiling found)
                       y*FUMQ  Call y with all coords and print the result

Can you tell us a little bit more about how your program works? I could not figure out your algorithm from the comments.

@flawr I added an explanation of my algorithm.

@Jaketube Thanks for the explanation, I really like the recursive approach!

Matlab, 292
I am sure this can be shortened a lot just by porting it into another language.
The basic idea is bruteforcing: I came up with kind of an enumeration of all ways how to place m*n/2 domino bricks on an m*n board. But this enumeration also includes many invalid tilings (bricks that overlap or go outside of the board.) So the program constructs all those tilings, and only counts the valid ones. The runtime complexity is about O(2^(m*n/2) * m*n). Memory is not a problem for the 8x8 as it only needs O(m*n) memory. But the time needed for 8x8 is about 20 days.
Here the fully commented version that explains what is going on.
PS: If anyone knows how to make the Matlab syntax highlighting work, please include the corresponding tag in this answer!
function C=f(m,n)
d = ceil(m*n/2);%number of dominoes
%enumeration: %the nth bit in the enumeration says whether the nth
% domino pice is upright or not. we enumerate like this:
% firt piece goes top left:
% next piece goes to the left most column that has an empty spot, in the
% top most empty spot of that column
C=0;%counter of all valid tilings
for e=0:2^d-1 %go throu all enumerations
    %check whether each enumeration is valid
    A = ones(m,n);
    %empty spots are filled with 1
    %filled spots are 0 (or if overlapping <0)
    v=1;%flag for the validity. hte grid is assumed to be valid until proven otherwise
    for i=1:d %go throu all pieces, place them in A
        %find the column where to place:
        c=find(sum(A)>0,1);
        %find the row where to place:
        r=find(A(:,c)>0,1);
        %find direction of piece:
        b=de2bi(e,d);
        if b(i)
            x=0;y=1;
        else
            x=1;y=0;
        end
        %fill in the piece:
        try
            A(r:r+y,c:c+x)=A(r:r+y,c:c+x)-1;
        catch z
            v=0;break;
        end
        %check whether A has no overlapping pieces
        if any(A(:)<0)
            v=0;break;
        end
    end
    %if valid, count it as valid
    if v && ~norm(A(:))
        disp(A)
        C=C+1;
    end
end

Here the fully golfed one:
function C=f(m,n);m=4;n=6;d=ceil(m*n/2);C=0;for e=0:2^d-1;A=ones(m,n);v=1;for i=1:d;c=find(sum(A)>0,1);r=find(A(:,c)>0,1);b=de2bi(e,d);if b(i);x=0;y=1;else;x=1;y=0;end;try;A(r:r+y,c:c+x)=A(r:r+y,c:c+x)-1;catch z;v=0;break;end;if any(A(:)<0);v=0;break;end;end;if v && ~norm(A(:));C=C+1;end;end

APL (Dyalog Extended), 26 bytes
{⍎0⍕√|×/⌾/¨2×2○○,⍵}⍳÷∘⊂1∘+

Try it online!
A monadic tacit function that takes a 2-element vector n m as its sole argument.
A port of fireflame241's Python answer, and in turn an implementation of the formula:
$$
T(n,k)^2 = \left| \prod^n_{a=1}{\prod^k_{b=1}{2 \cos \frac{a\pi}{n+1}+2i \cos \frac{b\pi}{k+1}}} \right|
$$
Turns out that the results before rounding are pretty accurate (under 1e-14 relative error for the test cases), except when the result is expected to be zero.
How it works
{⍎0⍕√|×/⌾/¨2×2○○,⍵}⍳÷∘⊂1∘+  ⍝ input←n m
                   ⍳        ⍝ 2D array of all pairs of 1..n , 1..m
                    ÷∘⊂     ⍝ divided by wrapped pair of
                       1∘+  ⍝ (n+1)(m+1)
{               ,⍵}  ⍝ Ravel the 2D array, giving a vector of pairs
           2×2○○     ⍝ 2×cos(pi × each number)
        ⌾/¨          ⍝ Convert each pair x,y to x + yi
      ×/  ⍝ Product of all complex numbers
     |    ⍝ Abs
    √     ⍝ Sqrt
 ⍎0⍕      ⍝ Round the number by converting to string with
          ⍝ zero digits under decimal point, then evaling it back

C89, 230 bytes
f(n,m,b)int*b;{int s,i;s=i=0;
while(b[i])if(++i==n*m)return 1;
if(i/n<m-1){b[i]=b[i+n]=1;s+=f(n,m,b);b[i]=b[i+n]=0;}
if(i%n<n-1&&!(b[i]|b[i+1])){b[i]=b[i+1]=1;s+=f(n,m,b);b[i]=b[i+1]=0;}
return s;}
g(n,m){int b[99]={};return f(n,m,b);}

For readability I handwrapped this answer - all newlines can safely be removed to get to 230 bytes.
Defines a function int g(int n, int m) that returns the number of tilings. It uses a helper function f that iterates over all valid tilings by placing one domino, recursing, and then removing the domino on a shared board.

JavaScript (ES7),  149 ... 145  142 bytes
Expects (n)(m).
m=>g=(n,a=[...Array(N=2**m-1).fill(0),1])=>n?g(n-1,a.map((_,i)=>a.reduce((p,c,k)=>p+c*!(h=(x,y)=>y&~x|(x?h(x>>1,x&!y):~k&~i&N))(k&i),0))):a[N]

Try it online!
How?
I've described the algorithm in my Python answer to Domino Recurrence Generator.
The main difference is that it's shorter in JS to combine both state compatibility tests into the following recursive function than to use a regular expression.
( h = (x, y) =>
    y & ~x | (
      x ?
        h(x >> 1, x & !y)
      :
        ~k & ~i & N
    )
)(k & i)

Python 3.8 (pre-release), 133 121 115 bytes
lambda m,n:round(abs(prod(2*cos((i//n+1)*pi/-~m)+2j*cos((i%n+1)*pi/-~n)for i in range(m*n)))**.5)
from math import*

Try it online!
(Python 3.8 adds math.prod for product)
-12 bytes thanks to @Bubbler
Implements the following formula (from OEIS A187596):
T(n,k)^2 = absolute value of Prod(Prod( 2*cos(a*Pi/(n+1)) + 2*i*cos(b*Pi/(k+1)), a = 1..n), b = 1..k), where i = sqrt(-1)

Since this multiplies (floating-point) complex numbers together, this loses precision for sufficiently large n, which is permitted by the challenge rules (effectively, data type overflows).

121 bytes

Python 243
I opted for a brute force approach:

generate m*n/2 directions;
try and fit the domino on the m*n board.

If they all fit and no spaces are left we have a valid entry.
Here is the code:
import itertools as t
m,n=input()
c,u=0,m*n
for a in t.product([0,1],repeat=u/2):
 l,k,r,h=[' ',]*u,0,'-|',[1,m]
 for t in a:
  l[k]=r[t]
  k+=h[t]
  if k%m<m and k/m<n and l[k]==' ':l[k]=r[t]
  k=''.join(l).find(' ',1)
 if k<0:c+=1
print c


text:
Approximate Square Formation
Background
I have a bunch of square-shaped boxes of equal size, and since I'm a neat person, I want to arrange them all into a square formation.
However, their number is not necessarily a perfect square, so I may have to approximate the square shape.
I want you to find me the most aesthetically pleasing arrangement -- programmatically, of course.
Input
Your input is a single positive integer k, representing the number of boxes.
Output
Your program shall choose two positive integers m, n such that m*(n-1) < k ≤ m*n holds.
They represent the width and height of the large square-like shape we are arranging.
Since we are looking for aestethically pleasing shapes, the quantity (m - n)2 + (m*n - k)2 shall be minimal, so that the shape is close to a square, and its area is close to k.
If there are still several candidates for the pair (m, n), choose the one where the width m is maximal.
Now, your actual output shall not be the numbers m and n.
Instead, you shall print the arrangement of boxes, using the character # to represent a box.
More specifically, you shall print n-1 rows, each of which consists of m characters #, and then one row of k - m*(n-1) characters #.
Note that the output contains exactly k characters #.
Rules and Scoring
There shall not be any leading or trailing whitespace in the output, except that the last row may be padded with trailing spaces to be of length m, if desired.
There may be one trailing newline, but no preceding newlines.
You may use any printable ASCII character in place of #, if desired.
You may write a full program, or return a string from a function.
The lowest byte count wins, and standard loopholes are disallowed.
Test Cases
Here are the correct outputs for a few input values.
1
#
2
##
3
##
#
4
##
##
8
###
###
##
13
#####
#####
###
17
######
######
#####
18
#####
#####
#####
###
20
#####
#####
#####
#####
21
######
######
######
###
22
######
######
######
####
23
#####
#####
#####
#####
###

Pyth, 28 bytes
jbc*\#Qho.a,,N*NJ_/_QN,JQ_SQ

Try it online.
The crux is that I sort potential m on the following property:
(m - ceil(k/m))^2 + (m*ceil(k/m) - k)^2

Note the total absence of n. The total shape is defined merely by m. Then I transform the above property once more, and my final sorting weight is defined as the Euclidean distance between the following two points:
(m, m*ceil(k/m)) and (ceil(k/m), k)

This changes the weight values, but not their ordering.

Python 3, 202 bytes
I know that its longer than the CJam or Pyth solutions, but nevertheless, here is a way of solving this problem in Python:
k=int(input())
r,d,s=range(k+1),{},'#'*k
for n in r:
 for m in r:
  if m*n>=k:
   d[m,n]=(m-n)**2+(m*n-k)**2
x,y=max(i for i in d.keys()if d[i]==min(d.values()))
[print(s[i*x:(i*x+x])for i in range(y+1)]

The basic principle is that we know m and n are both less than k. Also, m*n >= k . That means that we can simply find the minimum of the expression given in the challenge for all m,n < k, excluding values whose product is greater than k.

I actually count 231 bytes in your source, not 234. But regardless, you can reduce it by decreasing your indent size from four spaces to one space. It'll work the same.

This is a handy tool for getting your byte count. By the way, nice submission and welcome to the site!

: missing at line 5. Comma is what defines a tuple, brackets () can be removed at line 6. Spaces between ) and (if or for) too. max can get generator as parameter, thus brackets [] are redundant. You iterate over d keys, so you can safely use d[i].

You can save two bytes changing (i+1)*x to -~i*x or i*x+x.

You have an extra, invalid paren at (i*x+x...

CJam (44 42 bytes)
qi_,{)_2$d\/m]_2$-_*@@*2$-_*+~}$W=)'#@*/N*

Online demo
I was rather expecting there to be a simpler solution involving square roots, but it's not at all that simple. E.g. for input 31 the row width is two greater than the ceiling of the square root; for 273 (square root just over 16.5) the best approximate square is a perfect 21x13 rectangle.

CJam, 42 bytes
li:K_,f-{:XdK\/m]:YX-_*XY*K-_*+}$0='#K*/N*

Try it online
Explanation:
li    Get and interpret input.
:K    Store in variable K for later use.
_     Copy.
,     Build sequence [0 .. K-1].
f-    Subtract from K, to get sequence [K .. 1]. Larger values have to come
      first so that they are ahead in ties when we sort later.
{     Begin block for calculation of target function for sort.
  :X    Store width in variable X.
  d     Convert to double.
  K\/   Calculate K/X.
  m]    Ceiling.
  :Y    Store height in variable Y.
  X-    Calculate Y-X.
  _*    Square it.
  XY*   Calculate X*Y...
  K-    ... and X*Y-K
  _*    Square it.
  +     Add the two squares.
}$    Sort by target function value.
0=    Get first element, this is the best width.
'#K*  Build string of K '# characters.
/     Split using width.
N*    Join with newlines.


text:
A naturally occurring prime generator
There are quite a large number of prime generating functions. Pretty much all of them are constructed and are based on the sieve of Eratosthenes, the Möbius function or the Wilson's theorem and are generally infeasible to compute in practice. But there are also generators, that have a very easy structure and were found by accident.
In 2003 Stephen Wolfram explored a class of nested recurrence equations in a live computer experiment at the NKS Summer School. A group of people around  Matthew Frank followed up with additional experiments and discovered an interesting property of the simply recurrence
a(n) = a(n-1) + gcd(n,a(n-1))

with the start value of a(1) = 7. The difference a(n) - a(n-1) = gcd(n,a(n-1)) always seemed to be 1 or a prime. The first few differences are (OEIS A132199):
1, 1, 1, 5, 3, 1, 1, 1, 1, 11, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 23, 3, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 47, 3, 1, 5, 3, ...

If we only omit the 1s we get the following sequence (OEIS A137613):
5, 3, 11, 3, 23, 3, 47, 3, 5, 3, 101, 3, 7, 11, 3, 13, 233, 3, 467, 3, 5, 3,
941, 3, 7, 1889, 3, 3779, 3, 7559, 3, 13, 15131, 3, 53, 3, 7, 30323, 3, ...

Eric S. Rowland proved the primeness of each element in this list a few years later. As you can see, the primes are mixed and some of them appear multiple times. It also has been proven, that the sequence includes infinitely many distinct primes. Furthermore it is conjectured, that all odd primes appear.
Because this prime generator was not constructed but simply found by accident, the prime generator is called "naturally occurring". But notice that in practice this generator is also quite infeasible to compute. As it turns out, a prime p appears only after (p–3)/2 consecutive 1s. Nevertheless implementing this prime generator will be your task.
Challenge:
Write a function or a program that prints the first n elements of the sequence A137613 (the sequence without the 1s). You can read the input number n >= 0 via STDIN, command-line argument, prompt or function argument. Output the first n elements in any readable format to STDOUT, or return an array or a list with these values.
This is code-golf. Therefore the shortest code wins.
Leaderboard:
Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language. To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
# Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
# Ruby, <s>104</s> <s>101</s> 96 bytes

var QUESTION_ID=55272;function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),e.has_more?getAnswers():process()}})}function shouldHaveHeading(e){var a=!1,r=e.body_markdown.split("\n");try{a|=/^#/.test(e.body_markdown),a|=["-","="].indexOf(r[1][0])>-1,a&=LANGUAGE_REG.test(e.body_markdown)}catch(n){}return a}function shouldHaveScore(e){var a=!1;try{a|=SIZE_REG.test(e.body_markdown.split("\n")[0])}catch(r){}return a}function getAuthorName(e){return e.owner.display_name}function process(){answers=answers.filter(shouldHaveScore).filter(shouldHaveHeading),answers.sort(function(e,a){var r=+(e.body_markdown.split("\n")[0].match(SIZE_REG)||[1/0])[0],n=+(a.body_markdown.split("\n")[0].match(SIZE_REG)||[1/0])[0];return r-n});var e={},a=1,r=null,n=1;answers.forEach(function(s){var t=s.body_markdown.split("\n")[0],o=jQuery("#answer-template").html(),l=(t.match(NUMBER_REG)[0],(t.match(SIZE_REG)||[0])[0]),c=t.match(LANGUAGE_REG)[1],i=getAuthorName(s);l!=r&&(n=a),r=l,++a,o=o.replace("{{PLACE}}",n+".").replace("{{NAME}}",i).replace("{{LANGUAGE}}",c).replace("{{SIZE}}",l).replace("{{LINK}}",s.share_link),o=jQuery(o),jQuery("#answers").append(o),e[c]=e[c]||{lang:c,user:i,size:l,link:s.share_link}});var s=[];for(var t in e)e.hasOwnProperty(t)&&s.push(e[t]);s.sort(function(e,a){return e.lang>a.lang?1:e.lang<a.lang?-1:0});for(var o=0;o<s.length;++o){var l=jQuery("#language-template").html(),t=s[o];l=l.replace("{{LANGUAGE}}",t.lang).replace("{{NAME}}",t.user).replace("{{SIZE}}",t.size).replace("{{LINK}}",t.link),l=jQuery(l),jQuery("#languages").append(l)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",answers=[],page=1;getAnswers();var SIZE_REG=/\d+(?=[^\d&]*(?:<(?:s>[^&]*<\/s>|[^&]+>)[^\d&]*)*$)/,NUMBER_REG=/\d+/,LANGUAGE_REG=/^#*\s*([^,]+)/;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

While the prime generator is not constructed, you're effectively implementing a trial division using the recursion.

If a(1) = 7, why doesn't the sequence begin with 7?

@feersum because the sequence we are concerned with is a(n)-a(n-1)

Can n be zero?

Is it valid to install a PHP extension to make my code work?

@Sp3000 Yes, I'll update the specifications.

@jrenk Yes, if you want. Just make sure you include the 'call extension/include extension' part to the byte-count.

@Jakube I just need to uncomment one line in the php.ini. How should I count that?

@jrenk Not sure. Maybe count it as 2 bytes (since you're removing 2 chars //) and explain it in your submission. If anyone disagrees with you, you can always edit your post.

You have an error in your list from A312199. According to the link you provide (and my programs output), there should be a 23 and 3 between 11, 3 and 47, 3. The list from A137613 also shows 23 and 3.

@CoreyOgburn Thanks. Updated the question. No idea how I lost these two numbers.

You sent me back to the drawing board for half an hour wondering how I pulled that off.

Pyth, 14 13 bytes
meaYhP+sY-5dQ

Uses a(n) = Lpf(6 - n + sum(a(i) for i in range(1, n)) where Lpf means least prime factor.
Try it here online.

Python 3.5.0b1+, 95 93 bytes
Link to Python 3.5.0b1+ release
import math
def f(k,n=2,a=7,L=[]):x=math.gcd(n,a);return k and f(k-1%x,n+1,a+x,L+1%x*[x])or L

A direct implementation of the recurrence, featuring:

Our good friend 1%x, and
math.gcd, as opposed to fractions.gcd.

What does 1%x do? Side question: where do I find documentation of the revision history of Python that includes betas? Edit: Nevermind, found it at the bottom of the revision history.

@mbomb007 Since x >= 1, 1%x returns 0 if x == 1, 1 otherwise (used to decide whether to add x to the list)

Julia, 110 bytes
n->(a(n)=(n≥1&&(n==1?7:a(n-1)+gcd(n,a(n-1))));i=2;j=0;while j<n x=a(i)-a(i-1);x>1&&(j+=1;println(x));i+=1end)

Ungolfed:
function a(n::Int)
    n ≥ 1 && (n == 1 ? 7 : a(n-1) + gcd(n, a(n-1)))
end

function f(n::Int)
    i = 2;
    j = 0;
    while j < n
        x = a(i) - a(i-1)
        if x > 1
            j += 1
            println(x)
        end
        i += 1
    end
end

Wow, a perfect 8k, nice :D

Use n<2 instead of n==1. Also, if you look forwards instead of backwards, you can use i=1 and x=a(i)-a(i+=1), and then println(-x) and -x>1 to correct for the negativeness, thereby avoiding the need for a separate increment of i. And ≥ is three bytes, while >= is two... but then, you can use n<1||() rather than n>=1&&()... and yet, it's not even necessary in the first place (drop the conditional, n will never be less than 1). You also don't need the outermost brackets when defining a(n). With these changes, you should at least get down to 97 bytes.

PHP, 101 96 99 98 77 72 bytes
<?for(;2>$t=gmp_strval(gmp_gcd(~++$i,7+$e+=$t))or$argv[1]-=print"$t ";);

Usage:

Call the Script with an argument: php -d error_reporting=0 script.php 30

If you want to test it you need to uncomment ;extension=php_gmp.dll in your php.ini

--> extension=php_gmp.dll

Should I add the extension to my byte count? Any thoughts?

Log:

Saved 3 bytes thanks to Ismael Miguel.

Saved 26 bytes thanks to primo.

You can shorten your opening tag to <? and remove the definition of $j.

@IsmaelMiguel should the tag also count?

Yes, it counts. But you can remove that newline. Which will save 1-2 bytes, depending on how you counted your code size.

@IsmaelMiguel Thanks for the Help!

You're welcome. You still have an useless whitespace after the <?.

@IsmaelMiguel Now I'm with you! Didn't know I could do that thanks!

Minor improvements: Use < in $j<=$argv[1] (prints one too many) (-1). Leave $e uninitialized, use $e+7 instead (-3). Use for(;;) instead of while(), making use of the pre- and post-expressions (-2). Replace echo$t.' ';$j++ with $j+=print"$t ", drop the brackets (-3). Replace if($t>1) with 2>$t|| (-2). Combine the assignment to $t with the conditional, switch || for or, drop the brackets (-5). Move $argv[1] to the $j increment, move the entire expression to the for conditional (-2). Change >=$j+=print to -=print (-3). Step by step: http://codepad.org/s6LNSPSM

@primo thanks for the nice explanation! Didn't know I could do all that.

A few more: Combine $e+7 with $e+=$t (-2). Leave $i uninitialized, use ~++$i instead (-3). http://codepad.org/fDIImajp

@primo You are actually my hero now! Thanks

Rule of thumb for php: if you program doesn't look like <?for(;...;);, you're not done golfing ;)

Pyth, 30 bytes
Very badly golfed, can be considerably reduced. Defines recursive function at front, filters .first-n, and then maps the difference.
L?tb+KytbibK7m-yhdyd.ft-yhZyZQ

Try it here online.

This gives the wrong output for n = 0

@Sp3000 that is a bug in Pyth. I'll put in a pull request.

Bug found and fixed - patch will be implemented once github stops being DDoS'd.

Bug fixed - DDoS is slowly going away.

@isaacg: This reminds me of a Meta page where someone wanted to know whether PCG has achieved anything external, but I can't find the question.

Here it is: http://meta.codegolf.stackexchange.com/questions/5318/what-contributions-has-ppcg-made-to-the-fields-of-math-or-computer-science. Personally I'd consider bug fixes in programming languages as an answer

@ThomasWeller It kind of achieved the whole language ...

Perl 5.8 is quite possibly the most golfed language in history. Consequently, 5.10 had a lot of bug fixes.

Julia, 69 67 bytes
n->(i=1;a=7;while n>0 x=gcd(i+=1,a);a+=x;x>1&&(n-=1;println(x))end)

This is a simple iterative solution to the problem. x is the difference (which is the gcd), and then I update a by adding x.

I think it prints A231900.

@alephalpha - I think I see the error. Easily fixed. Even shaved two bytes off in the process.

Haskell, 51 bytes
d=zipWith gcd[2..]$scanl(+)7d
f=($filter(>1)d).take

Note that f is a function that will return the first n elements.
Rather than computing the a(n) and then working out the differences, we compute the differences d(n) and sum them together to get a(n). (Those unfamiliar with Haskell may protest that we need a(n) first in order to get d(n), but of course lazy evaluation gets us around this problem!)
Ungolfed:
a = scanl (+) 7 d        -- yielding a(n) = 7 + d(1) + d(2) + ... + d(n-1)
d = zipWith gcd [2..] a  -- yielding d(n) = gcd(n+1, a(n))

f n = take n $ filter (> 1) d -- get rid of 1s and take the first n

JavaScript (ES6), 91
Recursive gcd, iterative main function. Not so fast.
Usual note: test running the snippet on any EcmaScript 6 compliant browser (notably not Chrome not MSIE. I tested on Firefox, Safari 9 could go)

F=m=>{
  for(G=(a,b)=>b?G(b,a%b):a,o=[],p=7,n=1;m;d>1&&(o.push(d),--m))
    p+=d=G(++n,p);
  return o
}

O.innerHTML=F(+I.value)
<input id=I value=10><button onclick='O.innerHTML=F(+I.value)'>-></button>

Haskell, 74 71 66 bytes
f=($filter(>1)$tail>>=zipWith(-)$scanl(\x->(x+).gcd x)7[2..]).take

Used the trick here: https://codegolf.stackexchange.com/a/39730/43318, and made point-free.
(Previous: 71 bytes)
a=scanl(\x->(x+).gcd x)7[2..]
f m=take m$filter(>1)$zipWith(-)(tail a)a

First make the sequence of a's, and then take the differences.
(Previous: 74 bytes)
f m=take m$filter(>1)$map snd$scanl(\(x,d)->(\y->(x+y,y)).gcd x)(7,1)[2..]

Standard list functions, plus clever use of lambda function.
Note this is 1 byte shorter than the more obvious
g m=take m$filter(>1)$map snd$scanl(\(x,d)n->(x+gcd x n,gcd x n))(7,1)[2..]

If we don't count imports, I can get this down to 66.
import Data.List
h m=take m$filter(>1)$snd$mapAccumL(\x->(\y->(x+y,y)).gcd x)7[2..]

PARI/GP, 60 bytes
a(n)=a=7;i=1;while(n,if(1<d=gcd(i+=1,a),n-=1;print(d));a+=d)

Taken more or less straight from the definition a(n) - a(n-1) = gcd(n, a(n-1))
Output for a(20):
5
3
11
3
23
3
47
3
5
3
101
3
7
11
3
13
233
3
467
3

APL (Dyalog Extended), 24 bytes
{⍵<2:5⋄⊃⍭6-⍵-+/∇¨⍳⍵-1}¨⍳

{⍵<2:5⋄⊃⍭6-⍵-+/∇¨⍳⍵-1} dfn to calculate the nth element
⍵<2:5 if ⍵<2 return 5
⋄ else
∇¨⍳⍵-1 recursively find the first ⍵-1 terms
+/ sum them
6-⍵-s in APL is 6-(⍵-s) = 6-⍵+s, as APL is evaluated right to left
⊃⍭ take the first (least) prime factor
¨⍳ apply the function to the first n numbers, to find the first n elements
Try it online!
Old answer: 46 bytes
{l←⍵⋄{l≡≢r←1~⍨2-⍨/⍵:r⋄∇⍵,(+/(0,1+≢)∨1↑⌽)⍵}7 8}

Try it online!

Jelly, 13 10 bytes
’ßS_+6ÆfḢ)

Try it online!
Edit: I decided to revisit my oldest answer and found out that it can be very trivially golfed by 3 bytes. I sure have improved…
Uses the formula a(n) = Lpf(6-n+sum{i=1,...,n-1}a(i)).
Explanation
’ßS_+6ÆfḢ)   Main monadic link
         )   Map over the range [1..n]:
’              Decrement
 ß             Recursively apply this link
  S            Sum
   _           Subtract n
    +6         Add 6
      Æf       Prime factorization
        Ḣ      First element

Welcome to the site, and impressive first answer!

@cairdcoinheringaahing Thanks! I've been lurking for a long time and decided to finally join.

If you're interested in improving your Jelly skills/talking to other Jelly users, be sure to check out the Jelly Hypertraining chat room as well! (You'll need 20 rep to do so, but I have no doubt that you can gather a couple of upvotes for your answer)

C++, 193 182 180 172 bytes
Thanks @Jakube - saved 8 bytes on output.
int g(int a,int b){return a==b?a:a>b?g(b,a-b):g(a,b-a);}void f(int *r,int n){int m=1,i=0,a=7,b;while(i<n){b=g(a,++m);if(b>1){r[i]=b;++i;}a+=b;}}int main(){int r[6];f(r,6);}

You can probably save a few bytes by defining a function f, that returns an array with the results. This way you can remove the include, the scanf and the print.

Mathematica, 59 bytes
For[i=j=1;a=7,i<=#,,d=GCD[++j,a];If[d>1,Print@d;i++];a+=d]&

Husk, 13 bytes
↑¡ö▼p+6§-LΣ;5

Try it online!
Uses Shevelev's formula from A137613: a(n) = Lpf(6-n+sum{i=1,...,n-1}a(i)).
↑               # input-th element of
 ¡              # list of repeated application of
  ö             # 4 functions:
   ▼            # minimum of
    p           # prime factors of
     +6         # 6+
          Σ     # sum of list so far
       §-L      # minus length of list so far
           ;5   # starting with 5

Husk, 18 bytes
↑f←Ẋ-¡λS+ȯ⌋→L¹→);7

Try it online!
Alternative derivation (following the story of the question): difference between adjacent elements of a(n) = a(n-1) + gcd(n,a(n-1)) with a(1)=7, ignoring 1s.
↑                   # input-th element of
 f←                 # (without 1s)
   Ẋ-               # differences between adjacent elements of
     ¡              # list of repeated application of
      λ        )    # this function:
       S+     →     # sum of last element of list so far, plus
         ȯ⌋         # gcd of
           →        # last element of list so far, and
            L¹      # length of list so far
                ;7  # starting with 7

Japt -g, 12 bytes
n6+UÆßXÃÅx)k

Try it
Uses the LPF formula from the OEIS entry with a little bit of Japt trickery: when reducing a 2D-array by addition Japt just grabs the first element of each sub-array*.
n6+UÆßXÃÅx)k     :Implicit input of integer U
n                :Subtract U from
 6+              :  6 plus
   UÆ            :  Map each X in the range [0,U)
     ßX          :    Recursive call with argument U=X
       Ã         :  End map
        Å        :  Slice off the first element
         x       :  Reduce by addition (of first elements)
          )      :End subtraction
           k     :Prime factors of result
                 :Implicit output of first element of final array

*Or, for those interested, what actually happens is that each sub-array is run through JavaScript's parseFloat function coercing them to comma delimited strings and then parseFloat parses that string to an integer until it hits an illegal character, i.e. the first comma.


text:
Fond Memories of Past Primes
Consider a prime number p, written in base 10. The memory of p is defined as the number of distinct primes strictly less than p that are contained as substrings of p.
Challenge
Given a non-negative integer n as input, find the smallest prime p such that p has memory n. That is, find the smallest prime with exactly n distinct strictly lesser primes as substrings.
Input
Input can be taken through any standard format. You must support input up to the largest n such that the output does not overflow. For reference, 4294967291 is the largest prime in 32 bits.
Output
Output may be written to STDOUT or returned from a function.
Examples
The number 2 has memory 0 since it contains no strictly lesser primes as substrings.
The number 113 is the smallest prime with memory 3. The numbers 3, 13, and 11 are the only prime substrings and no prime smaller than 113 contains exactly 3 primes as substrings.
The first 10 terms of the sequence, beginning with n = 0, are
2, 13, 23, 113, 137, 1237, 1733, 1373, 12373, 11317

Note
This is A079397 in OEIS.
Leaderboard

var QUESTION_ID=55406,OVERRIDE_USER=20469;function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"http://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

Is there a limit on the running time?

@BetaDecay Nope.

Pyth, 22 bytes
f&}TPTqQlf}YPY{sMP.:`T

Demonstration, Test Harness
Explanation:
f&}TPTqQlf}YPY{sMP.:`T
                          Implicit: Q = eval(input())
f                         Starting at T=1 and counting up, return the first T where
                    `T    repr(T)
                  .:      all substrings
                 P        except T itself
               sM         converted to integers
              {           unique examples only
         f                filter on
          }YPY            Y is in the prime factorization of Y, e.g. Y is prime.
      qQl                 Q == len of the above, that is, T has memory Q,
 &}TPT                    and T is prime, (is in its prime factorization.)

Couldn't have you used P_Y and P_T instead of }YPY and }TPT back then?

CJam, 33 31 30 bytes
1{)__mp*{_mp2$s@s#)*},,easi^}g

This is a full program that reads the input as a command-line argument.
Try it online in the CJam interpreter.
Test run
$ time cjam <(echo '1{)__mp*,{_mp2$s@s#)*},,easi^}g') 9
11317
real    0m3.562s
user    0m4.065s
sys     0m0.177s

How it works
1       e# Push I := 1 on the stack.
{       e# Do:
  )__   e#   Increment I and push two copies.
  mp*   e#   Check the last copy for primality and multiply with the first copy.
        e#   This pushes R := I if I is prime and R := 0 if it is composite.
  {     e#   Filter; for each J in [0 ... R-1]:
    _mp e#     Push a copy of J and check for primality.
    2$s e#     Push a copy of I and cast to string.
    @s  e#     Rotate the original J on top of the stack and cast to string.
    #   e#     Find the index (-1 if not found) of the latter in the former.
    )*  e#     Increment the index and multiply it with the result from `mp'.
        e#     This yields 0 iff J is composite or not a subtring of I.
  },    e#   Keep J if the product is non-zero.
  ,     e#   Push the length of the filtered range.
  easi  e#   Cast the array of command-line arguments to string, then to integer.
  ^     e#   XOR it with the length of the filtered range.
}g      e# Repeat while theresult is non-zero.

CJam, 40 bytes
li2sa{_)\{1$\#)},,3$-}{i{)_mp!}gsa+}w]W=

Try it online
I'm sure this comes as a big shocker, but it is in fact longer than the solution Dennis posted. Well, not really, since I didn't even have very high hopes myself. But I wanted to give it a shot anyway. And since it's working, looks pretty reasonable to me, and I believe it is sufficiently different to at least be of some interest, I thought I'd post it anyway.
The basic idea here is that I build a list of prime numbers in a loop, adding the next larger prime number to the list in each step. To check for termination, I count how many elements other than the last element in the list are a substring of the last element. If this count is equal to the input n, we're done.
Explanation:
li    Get input and convert to integer.
2sa   Seed list of primes with ["2"]. The primes are stored as strings to make
      the later substring search more streamlined.
{     Start of while loop condition.
  _   Copy list of primes.
  )     Pop off last prime from list.
  \     Swap remaining list to top.
  {     Start of filter block for substring matches with all smaller primes.
    1$    Copy test prime to top.
    \     Swap the smaller prime to top to get correct order for substring search.
    #     Search.
    )     Increment to get truthy value (Search returns -1 if not found).
  },    End of filter. We have a list of smaller primes that are substrings now.
  ,     Count list entries.
  3$    Copy input n to top.
  -     Subtract the two for comparison. If they are different, continue loop.
}     End of while loop condition.
{     Start of while loop body. We need to generate the next prime.
  i     The largest prime so far is still on the stack, but as string.
        Convert it to integer.
  {     Start of loop for prime candidates.
    )     Increment current candidate value.
    _mp   Check if it is prime.
    !     Negate, loop needs to continue if it is not a prime.
  }g    End loop for prime candidates. On exit, next prime is found.
  sa+   Convert it to string, and add it to list of primes.
}w    End of while loop body.
]W=   Solution is at top of stack. Discard other stack entries.

Pyth - 25 bytes
Nested filter, inner to calculate memory, outer to find first that has required memory.
f&!tPTqlf&!tPY}`Y`TtStTQ2

Test Suite.

r2T instead of tStT

Brachylog (2), 12 bytes, language postdates challenge
~{ṗ≜{sṗ}ᵘkl}

Try it online!
This was previously 13 bytes, using ᶠd, but that's now been given an abbreviation ᵘ, cutting it down to 12. As the language postdates the challenge anyway, and the feature is one that wasn't added for this challenge in particular, I may as well use it.
As is usual in Brachylog, this is a function, not a full program.
Explanation
~{ṗ≜{sṗ}ᵘkl}
~{         }  Find a value for which the following is true:
  ṗ             The value is prime;
   ≜            (evaluation strategy hint; avoids an infinite loop)
    {  }ᵘ       The set of unique
     sṗ         substrings which are prime
          l     has a length equal to {the input}
         k      when one element is removed.

This gives us the smallest prime with the property we want, because ≜ checks values near 0 first.

Octave / Matlab, 126 bytes
function p=f(n)
p=1;t=1;while t
p=p+1;t=~isprime(p)|sum(arrayfun(@(x)any(strfind(num2str(p),num2str(x))),primes(p)))~=n+1;end

Try it online

JavaScript ES6, 106 bytes
n=>{for(a=[],i=2;a.filter(c=>(''+i).search(c)+1).length-n-1;a.push(i))while(!a.every(c=>i%c))i++;return i}

Here is an ungolfed version with explanation:
n=>{
  /**
   * a = list of primes
   * i = current integer
   * Iterate until number of members in a that are substring of i == n-1
   * After each iteration push the current value of i onto a
   */
  for(a=[],i=2; a.filter(c=>(''+i).search(c)+1).length-n-1; a.push(i)) {
    // Iterate until no member of a exactly divides i and increment i per iteration
    while(!a.every(c=>i%c)) i++;
  }
  return i;
}

Of course this gets horrendously slow rather quickly. However the OP has stated there is no limit on time.

Nice solution, ingenious use of a and i%c to check for prime-ness. You could save two bytes by changing {return i}else{a.push(i)} to return i;else a.push(i) I believe anonymous functions are allowed as well, which would save two more bytes at the beginning.

@ETHproductions Thanks didn't think of that. Although I've managed to shave off 7 bytes and remove all if...else logic by wrapping it in a for loop.

Wow, that's smart! What if you combined the i++ with i%c?

@ETHproductions Wouldn't work because that would iterate for every value of a and the next call would have the wrong i e.g., when we have found 10 primes it would iterate 10 times for each outer loop iteration.

@ETHproductions Ah yes I originally wanted to use recursion but it would have reached the stack limit before hitting the OP's minimum requirements. Now its refactored like this it should be possible... on it...

Julia, 86 bytes
n->for i=1:~0>>>1 isprime(i)&&sum(j->contains("$i","$j"),primes(i-1))==n&&return i;end

It's practically self-explanatory. Loop over all positive integers, and each time a prime is found, sum a boolean array indicating whether the set of primes less than the current one are substrings of the current one. If it finds one with the necessary number of matches, return that value.
Running time becomes sluggish for n=11, and likely for most values higher than 11 - specifically, on my laptop, n=11 takes about 33 seconds.

Clean and elegant solution, even though it only works on 64-bit system (blame Julia type system for that - on 32-bit platform 2^63 evaluates to 0, as Julia defaults Int32 for integer literals on 32-bit system - sic!). The shortest idiom to make the solution work on 32-bit system would be for i=1:uint(-1) then, but it costs 2 bytes more. However, it's hard to require testing golfed solutions on all platforms, so +1.

@pawel.boczarski - I can fix it, using bit-shifting. Have a look...

I also removed the "map", because it's redundant inside sum, as sum can take a function that is applied to each term before summing.

Python 2, 163 154 Bytes
I'm too tired to be golfing.. Hopefully when I wake up tomorrow I can improve this.
p=lambda n:all(n%x for x in range(2,n))
g=input()
s=2
while not(p(s)and len([l for l in[str(x)for x in range(2,s)if p(x)]if l in str(s)])==g):s+=1
print s

Husk, 14 bytes
ḟ(=⁰#ṗumdQd)İp

Try it online!

Vyxal, 14 bytes
λSǎ⌊Uæ∑?=næ∧;ṅ

Try it Online!
Takes input 1-indexed.
λ           ;ṅ # First positive integer where...
         næ    # Number is prime
           ∧   # And...
 Sǎ⌊U          # Unique substrings of number, as numbers
     æ∑        # Have a count of primes
       ?=      # Equal to the input?

Haskell, 149 147 144 bytes
(127 bytes not counting the import declaration).
import Data.List
i x=x`elem`nubBy(((>1).).gcd)[2..x]
f n=[p|p<-[2..],i p,n==length(nub[x|x<-[read b|a<-tails$show p,b<-tail$inits a],i x])-1]!!0

Prelude Data.List> map f [0..20]
  [2,13,23,113,137,1237,1733,1373,12373,11317,23719,Interrupted.

The above output was produced with the longer definition
i x=and$[x>1]++[rem x n>0|n<-[2..x-1]]

The new, 3 chars shorter, definition is much slower, I could only get 5 first numbers in the sequence before loosing patience and aborting.

PHP, 124 bytes
for($p=1;;){for($i=$c=0;$i-1;)for($i=++$p;$p%--$i;);$m[]=$p;foreach($m as$q)$c+=!!strstr($p,"$q");$c-1-$argv[1]?:die("$p");}

takes input from command line argument; run with -r.
breakdown
for($p=1;;)
{
    for($i=$c=0;$i-1;)for($i=++$p;$p%--$i;);    // find prime $p
    $m[]=$p;                                    // remember that prime
    foreach($m as$q)$c+=!!strstr($p,"$q");      // count memory primes
    $c-1-$argv[1]?:die("$p");                   // if memory==N, exit
}

Haskell, 119 118 bytes
p x=all((>0).mod x)[2..x-1]
f n=[y|y<-[2..],p y,n==sum[1|x<-[2..y-1],p x,elem(show x)$words=<<(mapM(:" ")$show y)]]!!0

Try it online! Usage: f 3 yields 113.

Python 2, 108 bytes
f=lambda n,x=2:n-sum(all(j%k for j in(i,x)for k in range(2,j))for i in range(2,x)if`i`in`x`)and f(n,x+1)or x

Try it online!