text:
tiny diamond square algorithm
The diamond square algorithm is a fractal terrain (heightmap) generating algorithm. You can find a nice description how it works here:
http://www.gameprogrammer.com/fractal.html (Used as a reference.)
http://www.playfuljs.com/realistic-terrain-in-130-lines/ (Great JS implementation, perhaps you might want to steal his renderer. Take a look here what this algorithm is capable of http://demos.playfuljs.com/terrain/.)
The general idea is that you have 4 corners as seeds (a), and calculate the height of the center point by averaging those four corners and adding a random value e.g. between -0.5 and 0.5 (b). If you apply this to the grid you get again a grid of diamonds  (squares turend 45°) and you repeat the same (c,d), but the random range gets smaller, e.g. -0.125 to 0.125 etc.

Your program must accept a number of inputs:

An integer l=1,2,3,... that determines the size of the square grid with side length 2^l+1. At l=10 you will have to store about one million numbers.
Four seeds (floating point) for each corner
A parameter 0<h<1 that determines the roughness (H in the link) that means how big the random range is initially
Parameters a,b that represent initial lower and upper bounds for the random range and get multiplied by h in each refinement step. (The random number is uniformly chosen between a and b.

The output must consist of the finished 2d grid.
So the rough algorithm would look like this:
Create a square grid with sidelength 2^l+1
Place seed values in the corners
Repeat:
  |  Perform square steps
  |  Refine Range: a = a*h; b=b*h;
  |  Perform diamond steps
  |  Refine Range

There is one detail you should be aware of: At the boundary of the grid, you will only have three vertices of the diamond, so you should also only calculate the average of those three points.
A visualization of some examples (please tell us what parameters you used) is optional but appreciated, and does of course not add to the byte count.
A slight variated implementation of this algorithm can be found here: Parallel projected voxel terrain generator
I created a small drawing function in javascript for displaing heightmaps in 2d as grayscale image. http://jsfiddle.net/flawr/oy9kxpsx/
If anyone of you is into fancy 3d and can make a script to view maps in 3d let me know!=)

Java, 1017 bytes
Input is a space separated list like so: l s1 s2 s3 s4 h a b.
Output is an 2d-array containing the numbers.
Program:
import java.util.*;import static java.lang.Math.*;class C{public static void main(String[]a){int b=a.length,d=0;float[]c=new float[b];for(;d<b;){c[d]=Float.parseFloat(a[d++]);}e=(int)(pow(2,c[0])+1);f=new float[e][e];f[0][0]=c[1];f[0][e-1]=c[2];f[e-1][0]=c[3];f[e-1][e-1]=c[4];g=c[5];float h=c[6],i=c[7];s(0,0,e-1,e-1,h,i);System.out.print(Arrays.deepToString(f));}static int e;static float[][]f;static float g;static void s(int q,int r,int s,int t,float h,float i){if(s-q<2|t-r<2|q<0|r<0|s>=e|t>=e)return;float o,p;int m=(q+s)/2,n=(r+t)/2;f[m][n]=(float)(a(q,r,s,r,q,t,s,t)+random()*(i-h)-h);d(m,r,m-q,o=h*g,p=i*g);d(q,n,m-q,o,p);d(m,t,m-q,o,p);d(s,n,m-q,o,p);}static void d(int x,int y,int e,float h,float i){float o,p;f[x][y]=(float)(a(x,y-e,x+e,y,x,y+e,x-e,y)+random()*(i-h)-h);s(x-e,y-e,x,y,o=h*g,p=i*g);s(x,y-e,x+e,y,o,p);s(x-e,y,x,y+e,o,p);s(x,y,x+e,y+e,o,p);}static float a(int...j){float k=0,l=0;for(int d=0;d<j.length;d+=2){if(j[d]<0|j[d+1]<0|j[d]>=e|j[d+1]>=e)continue;l++;k+=f[j[d]][j[d+1]];}return k/l;}}

Program that is indented and displays the map:
import java.util.*;
import java.awt.image.*;
import java.awt.*;
import javax.swing.*;
import static java.lang.Math.*;

class D{

    public static void main(String[]a){
        int b=a.length,d=0;
        float[]c=new float[b];
        for(;d<b;){
            c[d]=Float.parseFloat(a[d++]);
        }
        e=(int)(pow(2,c[0])+1);
        f=new float[e][e];
        f[0][0]=c[1];
        f[0][e-1]=c[2];
        f[e-1][0]=c[3];
        f[e-1][e-1]=c[4];
        g=c[5];
        float h=c[6],i=c[7];
        s(0,0,e-1,e-1,h,i);
        showImage(f);
    }

    static int e;
    static float[][]f;
    static float g;

    static void s(int q,int r,int s,int t,float h,float i){
        if(s-q<2|t-r<2|q<0|r<0|s>=e|t>=e)
            return;
        float o,p;
        int m=(q+s)/2,n=(r+t)/2;
        f[m][n]=(float)(a(q,r,s,r,q,t,s,t)+random()*(i+h)-h);
        d(m,r,m-q,o=h*g,p=i*g);
        d(q,n,m-q,o,p);
        d(m,t,m-q,o,p);
        d(s,n,m-q,o,p);
    }

    static void d(int x,int y,int e,float h,float i){
        float o,p;
        f[x][y]=(float)(a(x,y-e,x+e,y,x,y+e,x-e,y)+random()*(i-h)+h);
        s(x-e,y-e,x,y,o=h*g,p=i*g);
        s(x,y-e,x+e,y,o,p);
        s(x-e,y,x,y+e,o,p);
        s(x,y,x+e,y+e,o,p);
    }

    static float a(int...j){
        float k=0,l=0;
        for(int d=0;d<j.length;d+=2){
            if(j[d]<0|j[d+1]<0|j[d]>=e|j[d+1]>=e)
                continue;
            l++;
            k+=f[j[d]][j[d+1]];
        }
        return k/l;
    }

    public static void showImage(float[][] f){
        float maxHeight = Float.MIN_VALUE;
        float minHeight = Float.MAX_VALUE;
        for (float[] row : f){
            for (float height : row){
                if (height > maxHeight){
                    maxHeight = height;
                }
                if (height < minHeight){
                    minHeight = height;
                }
            }
        }
        int e = f.length;
        BufferedImage image = new BufferedImage(e, e, BufferedImage.TYPE_INT_RGB);
        for (int x = 0; x < e; x++){
            for (int y = 0; y < e; y++){
                Color color = Color.getHSBColor((float)((f[x][y] - minHeight)/(maxHeight - minHeight)), 1, 1);
                image.setRGB(x,y,color.getRGB());
            }
        }
        JFrame frame = new JFrame("Picture");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(new JComponent(){

            @Override
            public void paint(Graphics g){
                g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
            }

        });
        frame.setVisible(true);
        frame.setBounds(0,0,e,e);
    }

}

Here is a function in Java to show a map:
public static void showImage(float[][] map){
    float maxHeight = Float.MIN_VALUE;
    float minHeight = Float.MAX_VALUE;
    for (float[] row : map){
        for (float height : row){
            if (height > maxHeight){
                maxHeight = height;
            }
            if (height < minHeight){
                minHeight = height;
            }
        }
    }
    int size = map.length;
    BufferedImage image = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB);
    for (int x = 0; x < size; x++){
        for (int y = 0; y < size; y++){
            Color color = Color.getHSBColor((float)((map[x][y] - minHeight)/(maxHeight - minHeight)), 1, 1);
            image.setRGB(x,y,color.getRGB());
        }
    }
    JFrame frame = new JFrame("Picture");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new JComponent(){

        @Override
        public void paint(Graphics g){
            g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
        }

    });
    frame.setVisible(true);
    frame.setBounds(0,0,size,size);
}

All of these images have a size of 7. The 4 seeds are 5, 10, 15, and 20.
a and b are -10 and 10 respectively.
Roughness starts at .1 and increments by .1 up to 1.

Terrain generating code coming soon!!!
Images coming soon!!!

Thank you very much! Could you perhaps provide a class around that with all the necessary imports so no big modification is needed? That would be awesome!

@flawr I'm working on it.

Just got it working, if you know how to do it, it would be great if you could make the window show up 'uncollapsed'. At least on my machine you have to draw it open every time you start it. Here is how I completed the class: http://pastebin.com/pRAMst4d

This looks awesome! I especially like the elegant way you are dealing with the boundaries where one vertice is missing=)

@flawr The window won't be collapsed when you open it now.


text:
Generate the shortest De Bruijn
A De Bruijn sequence is interesting: It is the shortest, cyclic sequence that contains all possible sequences of a given alphabet of a given length.  For example, if we were considering the alphabet A,B,C and a length of 3, a possible output is:
AAABBBCCCABCACCBBAACBCBABAC

You will notice that every possible 3-character sequence using the letters A, B, and C are in there.
Your challenge is to generate a De Bruijn sequence in as few characters as possible.  Your function should take two parameters, an integer representing the length of the sequences, and a list containing the alphabet.  Your output should be the sequence in list form.
You may assume that every item in the alphabet is distinct.
An example generator can be found here
Standard loopholes apply

Can the integer representing the length of the sequences be larger than the number of unique letters?

Yes.  A binary sequence of length 4 would be 0000111101100101

"Your challenge is to generate a De Bruijn sequence in as few characters as possible" - Does this mean "code golf" or "get the shortest possible De Bruijn sequence length"?

Both.  To qualify, your program must output the shortest sequence possible, but to win, your program must be the shortest.

"A binary sequence of length 4 would be 0000111101100101" => 0100 1000 and 1010 are missing here... unless sequences can be read backwards? It's not told in the rules :)

I know it's not allowed, but I would just like to point out that Mathematica has a built-in for this: DeBruijnSequence[#,#2]& (albeit not in the core language but the Combinatorica package).

I'm sure this has been posted before, but maybe it was closed as a duplicate of this very similar question and deleted.

@xem: usually De Bruijn sequences include wraparound, which is where those missing sequences appear.

Pyth, 31 bytes
This is the direct conversion of the algorithm used in my CJam answer. Tips for golfing welcome!
Mu?G}H+GG+G>Hefq<HT>G-lGTUH^GHk

This code defines a function g which takes two arguments, the string of list of characters and the number.
Example usage:
Mu?G}H+GG+G>Hefq<HT>G-lGTUH^GHkg"ABC"3

Output:
AAABAACABBABCACBACCBBBCBCCC

Code expansion:
M                 # def g(G,H):
 u                #   return reduce(lambda G, H:
  ?G              #     (G if
    }H            #       (H in
      +GG         #          add(G,G)) else
    +G            #       add(G,
      >H          #         slice_end(H,
        e         #           last_element(
         f        #             Pfilter(lambda T:
          q       #               equal(
           <HT    #                 slice_start(H,T),
           >G     #                 slice_end(G,
             -lGT #                   minus(Plen(G),T))),
          UH      #               urange(H)))))),
  ^GH             #     cartesian_product(G,H),
  k               #     "")

Try it here

CJam, 52 49 48 bytes
This is surprisingly long. This can be golfed a lot, taking in tips from the Pyth translation.
q~a*{m*:s}*{:H\:G_+\#)GGHH,,{_H<G,@-G>=},W=>+?}*

The input goes like
3 "ABC"

i.e. - String of list of characters and the length.
and output is the De Bruijn string
AAABAACABBABCACBACCBBBCBCCC

Try it online here

Gosh CJam should be banned, it is not just made for one golfing task but it seems for every possible golfing task...

@flawr you should wait for a Pyth answer then :P

CJam, 52 49 bytes
Here is a different approach in CJam:
l~:N;:L,(:Ma{_N*N<0{;)_!}g(+_0a=!}g]{,N\%!},:~Lf=

Takes input like this:
"ABC" 3

and produces a Lyndon work like
CCCBCCACBBCBACABCAABBBABAAA

Try it here.
This makes use of the relation with Lyndon words. It generates all Lyndon words of length n in lexicographic order (as outlined in that Wikipedia article), then drops those whose length doesn't divide n. This already yields the De Bruijn sequence, but since I'm generating the Lyndon words as strings of digits, I also need to replace those with the corresponding letters at the end.
For golfing reasons, I consider the later letters in the alphabet to have lower lexicographic order.

Jelly, 15 bytes
ṁL*¥Œ!;`wⱮẠɗƇṗḢ

Try it online!
Pretty slow, uses a brute force approach with around an \$O(n \times m \times (n \times m)!)\$ complexity, where \$n\$ is the integer input and \$m\$ is the length of the string. Times out if both \$n\$ and \$m\$ are greater than 3 on TIO
How it works
The length of the De Bruijn sequence will always be \$m^n\$ and each symbol in the provided alphabet will occur the same number of times, \$m^{n-1}\$. Therefore, we generate the string with that many symbols, then filter its permutations to find valid De Bruijn sequences.
ṁL*¥Œ!ẋ2wⱮẠʋƇṗḢ - Main link. Takes an alphabet A on the left and n on the right
   ¥            - Last 2 links as a dyad f(A, n):
 L              -   Length of A
  *             -   Raised to the power n
ṁ               - Mold A to that length
    Œ!          - All permutations
             ṗ  - Powerset; Get all length n combinations of A. Call that C
           ʋƇ   - Filter the permutations P on the following dyad g(P, C):
      ẋ2        -   Repeat P twice
         Ɱ      -   For each element E in C:
        w       -     Is it a sublist of P?
          Ạ     -   Is this true for all elements of C?
              Ḣ - Take the first one

JavaScript (ES6) 143
Using Lyndon words, like Martin's aswer, just 3 times long...
F=(a,n)=>{
  for(w=[-a[l='length']],r='';w[0];)
  {
    n%w[l]||w.map(x=>r+=a[~x]);
    for(;w.push(...w)<=n;);
    for(w[l]=n;!~(z=w.pop()););
    w.push(z+1)
  }
  return r
}

Test In FireFox/FireBug console
console.log(F("ABC",3),F("10",4))

Output
CCCBCCACBBCBACABCAABBBABAAA 0000100110101111

Python 2, 114 bytes
I'm not really sure how to golf it more, due to my approach.
def f(a,n):
 s=a[-1]*n
 while 1:
    for c in a:
     if((s+c)[len(s+c)-n:]in s)<1:s+=c;break
    else:break
 print s[:1-n]

Try it online
Ungolfed:
This code is a trivial modification from my solution to more recent challenge.
def f(a,n):
    s=a[-1]*n
    while 1:
        for c in a:
            p=s+c
            if p[len(p)-n:]in s:
                continue
            else:
                s=p
                break
        else:
            break
    print s[:1-n]

The only reason [:1-n] is needed is because the sequence includes the wrap-around.

Powershell, 164 96 bytes
-68 bytes with -match O($n*2^n) instead recursive generator O(n*log(n))
param($s,$n)for(;$z=$s|% t*y|?{"$($s[-1])"*($n-1)+$x-notmatch-join"$x$_"[-$n..-1]}){$x+=$z[0]}$x

Ungolfed & test script:
$f = {

param($s,$n)                    # $s is a alphabet, $n is a subsequence length
for(;                           # repeat until...
    $z=$s|% t*y|?{              # at least a character from the alphabet returns $true for expression:
        "$($s[-1])"*($n-1)+$x-notmatch  # the old sequence that follows two characters (the last letter from the alphabet) not contains
        -join"$x$_"[-$n..-1]    # n last characters from the new sequence
}){
    $x+=$z[0]                   # replace old sequence with new sequence
}
$x                              # return the sequence

}

@(
    ,("ABC",  2, "AABACBBCC")
    ,("ABC",  3, "AAABAACABBABCACBACCBBBCBCCC")
    ,("ABC",  4, "AAAABAAACAABBAABCAACBAACCABABACABBBABBCABCBABCCACACBBACBCACCBACCCBBBBCBBCCBCBCCCC")
    ,("ABC",  5, "AAAAABAAAACAAABBAAABCAAACBAAACCAABABAABACAABBBAABBCAABCBAABCCAACABAACACAACBBAACBCAACCBAACCCABABBABABCABACBABACCABBACABBBBABBBCABBCBABBCCABCACABCBBABCBCABCCBABCCCACACBACACCACBBBACBBCACBCBACBCCACCBBACCBCACCCBACCCCBBBBBCBBBCCBBCBCBBCCCBCBCCBCCCCC")
    ,("ABC",  6, "AAAAAABAAAAACAAAABBAAAABCAAAACBAAAACCAAABABAAABACAAABBBAAABBCAAABCBAAABCCAAACABAAACACAAACBBAAACBCAAACCBAAACCCAABAABAACAABABBAABABCAABACBAABACCAABBABAABBACAABBBBAABBBCAABBCBAABBCCAABCABAABCACAABCBBAABCBCAABCCBAABCCCAACAACABBAACABCAACACBAACACCAACBABAACBACAACBBBAACBBCAACBCBAACBCCAACCABAACCACAACCBBAACCBCAACCCBAACCCCABABABACABABBBABABBCABABCBABABCCABACACABACBBABACBCABACCBABACCCABBABBABCABBACBABBACCABBBACABBBBBABBBBCABBBCBABBBCCABBCACABBCBBABBCBCABBCCBABBCCCABCABCACBABCACCABCBACABCBBBABCBBCABCBCBABCBCCABCCACABCCBBABCCBCABCCCBABCCCCACACACBBACACBCACACCBACACCCACBACBACCACBBBBACBBBCACBBCBACBBCCACBCBBACBCBCACBCCBACBCCCACCACCBBBACCBBCACCBCBACCBCCACCCBBACCCBCACCCCBACCCCCBBBBBBCBBBBCCBBBCBCBBBCCCBBCBBCBCCBBCCBCBBCCCCBCBCBCCCBCCBCCCCCC")
    ,("01",   3, "00010111")
    ,("01",   4, "0000100110101111")
    ,("abcd", 2, "aabacadbbcbdccdd")
    ,("0123456789", 3, "0001002003004005006007008009011012013014015016017018019021022023024025026027028029031032033034035036037038039041042043044045046047048049051052053054055056057058059061062063064065066067068069071072073074075076077078079081082083084085086087088089091092093094095096097098099111211311411511611711811912212312412512612712812913213313413513613713813914214314414514614714814915215315415515615715815916216316416516616716816917217317417517617717817918218318418518618718818919219319419519619719819922232242252262272282292332342352362372382392432442452462472482492532542552562572582592632642652662672682692732742752762772782792832842852862872882892932942952962972982993334335336337338339344345346347348349354355356357358359364365366367368369374375376377378379384385386387388389394395396397398399444544644744844945545645745845946546646746846947547647747847948548648748848949549649749849955565575585595665675685695765775785795865875885895965975985996667668669677678679687688689697698699777877978878979879988898999")
    ,("9876543210", 3, "9998997996995994993992991990988987986985984983982981980978977976975974973972971970968967966965964963962961960958957956955954953952951950948947946945944943942941940938937936935934933932931930928927926925924923922921920918917916915914913912911910908907906905904903902901900888788688588488388288188087787687587487387287187086786686586486386286186085785685585485385285185084784684584484384284184083783683583483383283183082782682582482382282182081781681581481381281181080780680580480380280180077767757747737727717707667657647637627617607567557547537527517507467457447437427417407367357347337327317307267257247237227217207167157147137127117107067057047037027017006665664663662661660655654653652651650645644643642641640635634633632631630625624623622621620615614613612611610605604603602601600555455355255155054454354254154053453353253153052452352252152051451351251151050450350250150044434424414404334324314304234224214204134124114104034024014003332331330322321320312311310302301300222122021121020120011101000")
) |% {
    $s,$n,$e = $_
    $r = &$f $s $n
    "$($r-eq$e): $r"
}

Output:
True: AABACBBCC
True: AAABAACABBABCACBACCBBBCBCCC
True: AAAABAAACAABBAABCAACBAACCABABACABBBABBCABCBABCCACACBBACBCACCBACCCBBBBCBBCCBCBCCCC
True: AAAAABAAAACAAABBAAABCAAACBAAACCAABABAABACAABBBAABBCAABCBAABCCAACABAACACAACBBAACBCAACCBAACCCABABBABABCABACBABACCABBACABBBBABBBCABBCBABBCCABCACABCBBABCBCABCCBABCCCACACBACACCACBBBACBBCACBCBACBCCACCBBACCBCACCCBACCCCBBBBBCBBBCCBBCBCBBCCCBCBCCBCCCCC
True: AAAAAABAAAAACAAAABBAAAABCAAAACBAAAACCAAABABAAABACAAABBBAAABBCAAABCBAAABCCAAACABAAACACAAACBBAAACBCAAACCBAAACCCAABAABAACAABABBAABABCAABACBAABACCAABBABAABBACAABBBBAABBBCAABBCBAABBCCAABCABAABCACAABCBBAABCBCAABCCBAABCCCAACAACABBAACABCAACACBAACACCAACBABAACBACAACBBBAACBBCAACBCBAACBCCAACCABAACCACAACCBBAACCBCAACCCBAACCCCABABABACABABBBABABBCABABCBABABCCABACACABACBBABACBCABACCBABACCCABBABBABCABBACBABBACCABBBACABBBBBABBBBCABBBCBABBBCCABBCACABBCBBABBCBCABBCCBABBCCCABCABCACBABCACCABCBACABCBBBABCBBCABCBCBABCBCCABCCACABCCBBABCCBCABCCCBABCCCCACACACBBACACBCACACCBACACCCACBACBACCACBBBBACBBBCACBBCBACBBCCACBCBBACBCBCACBCCBACBCCCACCACCBBBACCBBCACCBCBACCBCCACCCBBACCCBCACCCCBACCCCCBBBBBBCBBBBCCBBBCBCBBBCCCBBCBBCBCCBBCCBCBBCCCCBCBCBCCCBCCBCCCCCC
True: 00010111
True: 0000100110101111
True: aabacadbbcbdccdd
True: 0001002003004005006007008009011012013014015016017018019021022023024025026027028029031032033034035036037038039041042043044045046047048049051052053054055056057058059061062063064065066067068069071072073074075076077078079081082083084085086087088089091092093094095096097098099111211311411511611711811912212312412512612712812913213313413513613713813914214314414514614714814915215315415515615715815916216316416516616716816917217317417517617717817918218318418518618718818919219319419519619719819922232242252262272282292332342352362372382392432442452462472482492532542552562572582592632642652662672682692732742752762772782792832842852862872882892932942952962972982993334335336337338339344345346347348349354355356357358359364365366367368369374375376377378379384385386387388389394395396397398399444544644744844945545645745845946546646746846947547647747847948548648748848949549649749849955565575585595665675685695765775785795865875885895965975985996667668669677678679687688689697698699777877978878979879988898999
True: 9998997996995994993992991990988987986985984983982981980978977976975974973972971970968967966965964963962961960958957956955954953952951950948947946945944943942941940938937936935934933932931930928927926925924923922921920918917916915914913912911910908907906905904903902901900888788688588488388288188087787687587487387287187086786686586486386286186085785685585485385285185084784684584484384284184083783683583483383283183082782682582482382282182081781681581481381281181080780680580480380280180077767757747737727717707667657647637627617607567557547537527517507467457447437427417407367357347337327317307267257247237227217207167157147137127117107067057047037027017006665664663662661660655654653652651650645644643642641640635634633632631630625624623622621620615614613612611610605604603602601600555455355255155054454354254154053453353253153052452352252152051451351251151050450350250150044434424414404334324314304234224214204134124114104034024014003332331330322321320312311310302301300222122021121020120011101000

See also: One Ring to rule them all. One String to contain them all

Python 3, 72 bytes
f=lambda a,n:(a[:n]in a[1:])*a[n:]or max((f(c+a,n)for c in{*a}),key=len)

Try it online!

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:
Golf some quine stripes in different languages
You will choose m languages and write n programs in each language, each with length n*m. The kth program should output the kth character of each program, ordered by the program number.
For example, in this submission (for demonstration only; they can be any characters including newlines and tabs):
ABC
DEF
GHI

Program ABC should output ADG, and programs DEF and GHI should output BEH and CFI respectively.
All programs in the list must not be a normal quine. So ABC and ADG must be different. Same applies to the other two programs. Note that n*m must be at least 2 to make this possible.
You don't have to use your languages in specific order. So you can write two programs in language A, then three in language B, then another in language A again. But all languages must be used exactly the same number of times.
Leading / trailing newline in your program and output doesn't matter.
The answer with minimum n(m+10)/m3 wins. But I'll also award at least +100 bounty to the answer with most languages if it used at least 3 of them. Deadline for the bounty: after a week without improvement or Mar 1st, 2015 if no answer satisfied the criterion.
Rules about languages
You can use any languages with different names, or different versions which are generally considered different enough (such as Python 2/3, ECMAScript 5/6). But your programs must not output exactly the same thing in any other language you have used.

CJam, m=1, n=37, score=407
Here is my example answer. It used only one language: CJam.
{"_~"+s'A_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'B_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'C_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'D_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'E_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'F_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'G_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'H_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'I_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'J_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'K_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'L_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'M_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'N_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'O_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'P_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'Q_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'R_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'S_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'T_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'U_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'V_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'W_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'X_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'Y_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'Z_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'[_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'\_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s']_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'^_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'__'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'`_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'a_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'b_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'c_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'd_'I={;;'f,'Ai>}{'A-=37*}?}_~
{"_~"+s'e_'I={;;'f,'Ai>}{'A-=37*}?}_~

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


text:
Super Square Rain
The Scream™ Winter Sale is on and you just nabbed yourself an intense minimalist action game, Super Square. Upon playing it, you come to the realisation that either the game's just ridiculously hard or you're just really bad at it. In particular, there's this "rain" pattern that seems to get you every time...

Frustrated, you decide to give yourself a different challenge: Draw the rain pattern in ASCII art!
Input
Input is a single positive integer indicating the size of the pattern n, given via STDIN or function argument.
Output
Output is the rain pattern at the specified size, returned as a string or printed via STDOUT. Leading or trailing whitespace before or after the entire image is okay. Additionally, the image need not be flush to the left of the screen, but must be clearly discernible.
Here's n = 10:
 ...................
| ----------------- |
|  ...............  |
| | ------------- | |
| |  ...........  | |
| | | --------- | | |
| | |  .......  | | |
| | | | ----- | | | |
| | | |  ...  | | | |
| | | | | - | | | | |
| | | | |   | | | | |
| | | | | - | | | | |
| | | |  ...  | | | |
| | | | ----- | | | |
| | |  .......  | | |
| | | --------- | | |
| |  ...........  | |
| | ------------- | |
|  ...............  |
| ----------------- |
 ...................

Here's n = 5:
 ---------
  .......
 | ----- |
 |  ...  |
 | | - | |
 | |   | |
 | | - | |
 |  ...  |
 | ----- |
  .......
 ---------

And finally, here's n = 1 (just the innermost two walls):
 -

 -

Construction (for extra clarity)
The playing area is divided into two pairs of quadrants like so:
 AAAAAAAAA
B AAAAAAA B
BB AAAAA BB
BBB AAA BBB
BBBB A BBBB
BBBBB BBBBB
BBBB A BBBB
BBB AAA BBB
BB AAAAA BB
B AAAAAAA B
 AAAAAAAAA

The upper/lower quadrants should alternate between horizontal walls represented by hyphens -, and gaps shaded with dots .. The left/right quadrants should alternate between spaces  and vertical walls represented by pipes |. The main diagonals are empty, and should always be filled with spaces.
The rain pattern of size n has 2n walls, with walls from the upper/lower quadrants closest to the centre and walls alternating between quadrants as we move away from the centre.
Scoring
This is code-golf, so the code in the fewest bytes wins.

This game... I know what you are talking about. It stole like 40 hours of my life until I beat it. ^^

super. hexagon.

CJam, 93 87 78 61 59 bytes
ri:K_+){K" |"*KKI-z:I-I2%:L+<SL>\+_W%L'-'.?I2*Ig-*@I0=>N}fI

Takes value n via STDIN
Few examples:
1
 -

 -
2
 ...
| - |
|   |
| - |
 ...
5
 ---------
  .......
 | ----- |
 |  ...  |
 | | - | |
 | |   | |
 | | - | |
 |  ...  |
 | ----- |
  .......
 ---------
10
 ...................
| ----------------- |
|  ...............  |
| | ------------- | |
| |  ...........  | |
| | | --------- | | |
| | |  .......  | | |
| | | | ----- | | | |
| | | |  ...  | | | |
| | | | | - | | | | |
| | | | |   | | | | |
| | | | | - | | | | |
| | | |  ...  | | | |
| | | | ----- | | | |
| | |  .......  | | |
| | | --------- | | |
| |  ...........  | |
| | ------------- | |
|  ...............  |
| ----------------- |
 ...................

This can be golfed a lot, which I will do first thing tomorrow.
Try it online here

Haskell 150 bytes
I realize it's not going to win, just wanted to post my first codegolf :D
q n=putStr$unlines$iterate(\l->let[a,b]=if l!!0!!1=='-'then"|."else" -";c=[a:s++[a]|s<-l];t=' ':[b|x<-l!!0]++" "in t:c++[t])[" - ","   "," - "]!!(n-1)

Use by loading into GHCi and calling q n where n is the size.
Some examples:
*Main> q 1
 -

 -
*Main> q 2
 ...
| - |
|   |
| - |
 ...
*Main> q 5
 ---------
  .......
 | ----- |
 |  ...  |
 | | - | |
 | |   | |
 | | - | |
 |  ...  |
 | ----- |
  .......
 ---------
*Main> q 10
 ...................
| ----------------- |
|  ...............  |
| | ------------- | |
| |  ...........  | |
| | | --------- | | |
| | |  .......  | | |
| | | | ----- | | | |
| | | |  ...  | | | |
| | | | | - | | | | |
| | | | |   | | | | |
| | | | | - | | | | |
| | | |  ...  | | | |
| | | | ----- | | | |
| | |  .......  | | |
| | | --------- | | |
| |  ...........  | |
| | ------------- | |
|  ...............  |
| ----------------- |
 ...................

Someone can probably do better, I'm fairly new to Haskell.

Don't worry about winning. ;) Winning is for CJam and Pyth. Golfing in other languages is about beating submissions in the same "weight class", and learning some new obscure features of your language. Welcome to PPCG!

Python, 204,198,191 bytes
r=lambda a,b,d=' ':d.join((a,b,a[::-1]))
def f(s,i,n):d=[r(s[:i],'.-'[(n-i)%2]*((n-i)*2-1))];return i==n and[r(s,' '*(2*(i%2)+1),'')]or d+f(s,i+1,n)+d
g=lambda n:'\n'.join(f('| '*(n/2),0,n))

"r" is a utility function that writes "b" surrounded by reflected "a", with an optional delimiter, (yes lambda parameters can have defaults).
"f" is recursive, generating sides and middle parts for each level
"g" is the rain function, which can be called with an integer to return the text requested.

I just realised I forgot to allow functions which return strings, which I usually permit (have edited that in). You can still save on a few chars by removing whitespace and putting lines 4, 5 on one line :)

With a bit of short circuit evaluation you can get this down to 190 :) link

Sorry, I downvoted you by an accident. I can cancel it if you edit.

Vyxal j, 43 bytes
ʀ›ƛ?∷-½⌊‛| ?∷ßṘ*ð?∷ßðn?+∷*⁰n-›:‛.-$i*Ṡøm;øm

Try it Online!
A bit of a mess, but it works!

Perl 5: 74 bytes (73 code + -p)
#!perl -p
s/.*/ /;$a=qw(- .)[$|--]x
s/.+/$"$&$"/g,s/^|\z/ $a
/g,$"^="\\"for($_)x$&

Takes parameter on the input (end of line character required for proper function):
$ perl rain.pl <<<"3"
 -----
  ...
 | - |
 |   |
 | - |
  ...
 -----

Ungolfed:
                         # Read the input line into $_ (-p)
s/.*/ /;                 # Replace the input with a space (plus the original eol), saves the parameter in $&
for(($_)x$&) {           # Iterate $& times without affecting $_
  $c=s/.+/$"$&$"/g;      # Add $" (initially space) at the start and the end of each line, stores number of lines in $c
  $a=("-",".")[$|--]x$c; # Set $a to $c times minus or dot using magic $| (which iterates over 1 and 0 on decrement)
  s/^|\z/ $a \n/g;       # Equivalent to $_=" $a \n$_ $a \n"
  $"^="\\";              # Alternate $" between space and bar using the string xor
}
                         # Print $_ (-p)

Japt -R, 25 bytes
This ended up being longer than I expected, especially once I'd realised I'd gotten the pattern completely wrong! So I may be able to get it down smaller with a different method, but this'll do for now.
ôÈçXg-i.¹²Åû3wXÑÄÃûSi|)Ôê

Try it
ôÈçXg-i.¹²Åû3wXÑÄÃûSi|)Ôê     :Implicit input of integer
ô                             :Range [0,input]
 È                            :Map each X
  ç                           :  X times repeat
   Xg                         :    Index X into
     -i.                      :      "-" prepended with "."
        ¹                     :  End repeat
         ²                    :  Repeat twice
          Å                   :  Slice off the first character
           û                  :  Centre pad with spaces to length
            3w                :  Maximum of 3 and
              XÑ              :    X*2
                Ä             :    Plus 1
                 Ã            :End map
                  û           :Centre pad each to the length of the longest with
                   S          :  Space
                    i|        :  Prepended with "|"
                      )       :End padding
                       Ô      :Reverse
                        ê     :Palindromise
                              :Implicit output joined with newlines

Python 3.8 (pre-release), 120 bytes
def f(s):W=[(~s%2+i)//2*"| "+(~s-i)%2*" "+(s-i)*"'-"[i+s&1]for i in range(s+1)];[print(i+i[-2::-1])for i in W+W[-2::-1]]

Try it online!


text:
Stack the Christmas Gifts
Someone has been hastily stacking the Christmas presents, and it's quite a mess:
           ========================
           |                      |
           ========================
     =============
     |           |
     |           |
     |           |
     |           |
     |           |
     |           |
     =============
        =======
        |     |
        |     |
        |     |
        =======
  ===================
  |                 |
  |                 |
  |                 |
  ===================
=================
|               |
|               |
|               |
|               |
=================
   =======
   |     |
   |     |
   =======

Like, seriously, how does that top present even balance. It's probably a hammer. To prevent this tower of presents from crumbling, you're to reorder the presents so they stack nicely:
        =======
        |     |
        |     |
        =======
        =======
        |     |
        |     |
        |     |
        =======
     =============
     |           |
     |           |
     |           |
     |           |
     |           |
     |           |
     =============
   =================
   |               |
   |               |
   |               |
   |               |
   =================
  ===================
  |                 |
  |                 |
  |                 |
  ===================
========================
|                      |
========================

The Rules

Each present consists of a top and bottom of = characters, and one or more middle rows, consisting of two | separated by spaces. The width of the present is the same in all its rows.
There are no empty lines.
Consecutive presents will overlap in at least one column.
Presents are to be stacked in order of decreasing width. In the event of a tie, the taller present should go below the flatter present.
Presents should be centred on the present beneath. If the present cannot be placed exactly in the centre (because the difference in widths is odd), you may choose either position that is half a character off the centre.
You may or may not assume that the input has a single trailing newline, but please state your assumption.
Your solution does not have to work for an empty input, but must be able to handle a single present.
You may write a program or function, which takes input via STDIN or function argument and returns the result or prints it to STDOUT.
This is code golf, so the shortest answer (in bytes) wins.

CJam, 81 70 bytes
'"qN/{__Sm0=#>}%N*"=
="/"=\"\"="*'"++~]$_W='=/,f{1$'=/,m4/\N/\f{S*\N}}

So we have to stack the Christmas presents? This code does it like an actual person would do*.
First, we stack all the presents against a wall to easily move them up and down using this code:
'"qN/{__Sm0=#>}%N*

then, we identify each present as a separate item using this code:
"=
="/"=\"\"="*'"++~]

then, we sort the presents based on their heights and widths using this code:
$

Till now, all the gifts have been stacked against a wall in order to have perfect alignment with each other. But as this is Christmas, we want to place the gifts aligned centered like a Christmas tree! This code does that:
_W=Af{1$Am4/\N/\f{S*\N}}

Here is a step by step output of the code for example in the question:
"Step 1 - Stack the presents against a wall";
========================
|                      |
========================
=============
|           |
|           |
|           |
|           |
|           |
|           |
=============
=======
|     |
|     |
|     |
=======
===================
|                 |
|                 |
|                 |
===================
=================
|               |
|               |
|               |
|               |
=================
=======
|     |
|     |
=======

"Step 2 - Identify the presents as a collection of presents";
["========================
|                      |
========================" "=============
|           |
|           |
|           |
|           |
|           |
|           |
=============" "=======
|     |
|     |
|     |
=======" "===================
|                 |
|                 |
|                 |
===================" "=================
|               |
|               |
|               |
|               |
=================" "=======
|     |
|     |
======="]

"Step 3 - Sort on height & width, with presents stacked against a wall to help sort them";
=======
|     |
|     |
=======
=======
|     |
|     |
|     |
=======
=============
|           |
|           |
|           |
|           |
|           |
|           |
=============
=================
|               |
|               |
|               |
|               |
=================
===================
|                 |
|                 |
|                 |
===================
========================
|                      |
========================

"Final step - stack them like a Christmas Tree";
        =======
        |     |
        |     |
        =======
        =======
        |     |
        |     |
        |     |
        =======
     =============
     |           |
     |           |
     |           |
     |           |
     |           |
     |           |
     =============
   =================
   |               |
   |               |
   |               |
   |               |
   =================
  ===================
  |                 |
  |                 |
  |                 |
  ===================
========================
|                      |
========================

Try it online here
* Might differ from person to person though :P

That's awesome that the standard lexicographic order happens to fulfill the sorting requirements! Nice catch.

@WChargin yeah. Saved me a ton of bytes!

Japt, 18 bytes
mx óÈíY b'=²Ãn c û

Try it online!
I use a sufficiently different strategy from the other Japt answer that I thought it was worth its own answer. Takes input and output as an array of lines
Explanation:
mx                    #Trim leading whitespace from each line
   ó        Ã         #Split the array between lines where:
    ÈíY               # The lines interleaved (e.g. "abc","def" => "adbecf")
        b'=²          # starts with "=="
             n        #Default sorting for "array of arrays of strings"
               c      #Flatten to a single array of lines
                 û    #Pad each line so they are centered

I don't know precisely why "default sort" works like that, but I've tested that the taller box of the two with the same width is on the bottom regardless of which comes first in the input.

Imagine that the shorter string gets right-padded with an imaginary character with code point -1 to the length of the longer one.

Replace "==" with '=² to save a byte.

Ruby, 164
Neat challenge! Couldn't get it down much further.
f=->x{y=x.scan(/\s+=+[\s|]+\s+=+/).sort_by{|p|-p.count(?|)}.sort_by{|p|p.count ?=}
y.map{|p|p.gsub(/^\s+/,'').each_line{|l|puts l.strip.center(y[-1].count(?=)/2)}}}

Explanation
The input String is chopped up into an Array where each present is an element. Then the array is sorted by the number of pipe characters and sorted again by the number of equal signs.
It then removes all leading whitespace and prints each line individually, centered by the width of the largest present.
It behaves the same with or without a trailing newline on the input.
Readable version
f = lambda do |x|
  y = x.scan(/\s+=+[\s|]+\s+=+/)
       .sort_by { |p| -p.count("|") }
       .sort_by { |p|  p.count("=") }

  y.map do |p|
    p.gsub(/^\s+/,'').each_line do |l|
      puts l.strip.center(y.last.count("=") / 2 )
    end
  end
end

05AB1E, 23 20 bytes
|ðδÛ»…=
=…=0=:0¡{».c

-3 bytes thanks to @ErikTheOutgolfer.
Try it online.
Explanation:
|         # Take the input split by newlines
 ðδÛ      # Remove leading spaces from each line
    »     # And join everything back together again with a newline delimiter
…=
=         # Push string "=\n="
 …=0=     # Push string "=0="
     :    # Replace all "=\n=" with "=0="
0¡        # Now split on "0"
          # (We now have our list of presents without any leading spaces)
  {       # Sort this list (with default string-wise sorting)
   »      # Join the list of presents by newlines
    .c    # Left-focused centralize the string (and output implicitly)

Notes:

Odd-width presents are left-focused centralized. This can be changed to right-focused by changing the trailing lowercase c to an uppercase C.
The leading | can be dropped if we are allowed to take the input as a list of string-lines.
Assumes the input contains no trailing spaces for any of the presents (similar as the input in the challenge description); trailing newlines are fine, since the | removes those anyway.

20 bytes. ðδÛ can be used instead of εðÛ} here, ¶'=.ø is the same as …=\n= (\n means newline), 0'=.ø is the same as …=0=.

@EriktheOutgolfer Ah, I'm an idiot for using .ø instead of the literal 3-char strings.. And thanks for ðδÛ. Actually never used δ before and had no idea it worked like that.

Attache, 91 bytes
Join&lf@{Center&#(_@-1@0)@>_}@{SortBy[&{#_'#__},Strip@>Lines=>Split[_,/"(?<==)\\s+(?==)"]]}

Try it online!
Ungolfed
?? returns [length of first entry, number of entries]
revDim := &{#_'#__}

?? regex
SPLIT_ON_BARRIERS := /"(?<==)\\s+(?==)"

splitPresents[str] := (
    chopped .= Split[str, SPLIT_ON_BARRIERS];;
    normalized .= Strip @> Lines => chopped
)

orderPresents[presents] :=
    SortBy[revDim, presents]

fixPresents[ordered] := (
    ?? number of columns of bottom-most present
    pad_size .= Size[Last[ordered][0]];;
    ?? center each line of each present
    Center&pad_size @> _
)

joinNewlines := Join&lf

stackPresents := joinNewlines@fixPresents@orderPresents@splitPresents

Japt, 23 20 19 bytes
Similar approach to Kevin's solution. First byte can be removed if we can take input as an array of lines.
·mx ·r¥¬·È·Ãq, n ·û

Try it
·mx ·r¥¬·È·Ãq, n ·û     :Implicit input of string
·                       :Split on newlines
 m                      :Map
  x                     :  Trim
    ·                   :Join with newlines
     r                  :Global replace
      ¥                 :  Shortcut for the == operator. Passing an operator as the first argument of a method in Japt implicitly converts it to a string
       ¬                :  Split
        ·               :  Join with newlines, giving the string "=\n=" to be replaced
         È              :  Pass each match through a function
          ·             :    Split on newlines. As we're working within a string, the resulting array gets cast to a string (i.e., "=\n=" -> ["=","="] -> "=,="
           Ã            :End replace
            q,          :Split on ","
               n        :Sort
                 ·      :Join with newlines
                  û     :Centre pad each line with spaces to the length of the longest

Python 2, 221 196 bytes
s,a,b,i=[c.strip()for c in input().split("\n")]+["="],[],[],0
exec"a+=[s[i].center(max(map(len,s)))]\nif s[i][0]==s[i+1][0]=='=':b+=[a];a=[]\ni+=1;"*(len(s)-1)
for c in sorted(b):print"\n".join(c)

Try it online!
Expects a quoted string without trailing newlines as input.
Not great, but it's the best I can do.

Perl 5 -n0, 123 bytes
sub k{pop=~y/=//}say s+^\s*+$"x((k($p[-1])- k$_)/4)+rmge for@p=sort{k($a)- k$b||$a=~y/|//-$b=~y/|//}/\s*(=+[|
]+\s*\=+)/gs

Try it online!

Javascript 279 bytes 275 bytes

I am something of a novice to code-golf, and not anything like an expert in javascript but the challenge is interesting and fun. I would like to see what tricks a real expert in js would use.
Assumptions

Input and output are arrays of strings
No blank lines anywhere
Height of a box is <= 99 lines (does this disqualify me)?
Input and output variables are predefined, output being initially an empty array

Code
Input is in g[]. Output in m[].
a=[];s='';b=0;c=0;o=[];g.forEach((t,x)=>{t=t.trim(),c=Math.max(c,t.length);o.push(t);if(s==''){s=t;b=x}else{if(t==s){a.push({"K":s.length*100+x-b,"O":o});s='';o=[]}}});a.sort((p,q)=>{return p.K-q.K});a.forEach((t)=>{t.O.forEach((q)=>{m.push(" ".repeat((c-q.length)/2)+q)})});

The code works by

building an array of objects, each object representing one box, with two members:
K, a sort key being the (width x 100 + height)
and O, an array of the (trimmed) strings making up the box. While building the array the code remembers the width of the widest box.
The array of box objects is sorted into order by the key K. Where boxes have the same width the key ensures they are sorted by height.
After sorting the boxes, the strings for each box are pushed into the output array with leading spaces added, which position the box centrally over the widest one.

Try it online!


text:
Minimum number of coins to get -closest- to target value?
There's the old, well hashed version of the question that uses Dynamic Programming to calculate the minimum number of coins to reach a target value, but what if the coins you're given can't reach the target (such as {4, 8, 12} trying to total 33)? What if you're satisfied with "close enough" totals?
It seems to me that there's two considerations with this:
1) Getting as close to the target value as possible, and
2) Using as few coins as possible.
For example, given a target value of X, if you an reach X-1 with 5 coins, but X-2 with only 2 coins, (where X is sufficiently large that 1 and 2 are almost equal in relative value [such as 500, as opposed to 5]), then it seems that X-2 with 2 coins could be the "better" answer, even though it's not the closest total to the target value.
How would one go about setting up this problem? It's too ambiguous for me to wrap my head around.

This question is not yet ready to be released as a challenge and should be moved to the sandbox.

Your definition of "How close is enough" and "close vs less coins" is very vague.


text:
Print all odd numbers from 0 to 100000
My teacher gave me a simple problem which I should solve with a code tiny as possible. I should print all odd numbers from 0 to 100000 into a HTML document using javascript.
for(var y = 0; y < 100000; y++){
if(!(y % 2 == 0)){
document.write(y + " ");
}
};

Is it possible to do that shorter?

By shorter do you mean Javascript only or any language?

The problem should be solved in JS only.

-1 for needlessly restriction on the language

@JohannesKuhn language-specific questions asking for golfing advice are perfectly on-topic

-1 for asking us to do your homework better.

The non-golfed Perl6 answer would be: say "{ 1, 3, 5, 7 ...^ *>100000 }" The golfed version would be: say "{1,3...9 x 5}" or say "{1,3...99999}"

Read this: http://codegolf.stackexchange.com/questions/2682/tips-for-golfing-in-javascript

Did you teacher specify that only the odd numbers were to be printed?

JavaScript, 38 bytes
Yet another way to do this, shortest of all.
This supposedly prints each number on a new line using \n. Now as the data is being written to an HTML document, \n is not of any use and the numbers appear to be separated by space only.

for(i=1;i<1e5;i+=2)document.writeln(i)

Just edit your existing answer(s)

@proudhaskeller more rep this way ;)

Or the alternative for(i=0;++i<1e5;)document.writeln(i++). I've found plenty, but none beats 38. Good job.

Javascript, 36 bytes
If order doesn't matter:
for(i=1e5;i--;)document.writeln(i--)

Writes the numbers in reverse order.

another way to do it in 38 bytes:
for(i=0;i<5e4;)document.writeln(i+++i)

explanation:i+++i means the same as (i++)+i, with the second i resolving to its new value (as effected by the ++) so it goes like this for the results:

0+1=1
1+2=3
2+3=5

etc...

Can you explain the i+++i condition? Thanks

@NiCkNewman  see edit.

Learn something new everyday, thanks Jasen.

JavaScript, 40 bytes

for(i=1;i<1e5;i+=2)document.write(i+" ")

The code is fairly straight forward.

I iterate from i=1 to i=1e5. 1e5 is nothing but 1 followed by 5 0, so 100000.
In each iteration step, I print the value of i and increment i by 2. Thus printing only every other number starting from 1 and till 100000.

This prints all the odd numbers from 1 to 100000.

JavaScript, 40 bytes
Another way to do it!

for(i=0;i<5e4;)document.writeln(2*++i-1)

The code is fairly straight forward.

Iterate from i = 0 to i = 5e4. 5e4 is nothing but 5 followed by 4 0, so 50000.
In each iteration step, print the value of 2*i - 1 after incrementing i by 1. Thus printing only odd numbers from 1 to 99999.

Using while 42
i=-1;while((i+=2)<10e5)document.writeln(i)


text:
Generate any random integer
Your program/function should

output exactly one integer
output any integer with positive probability
output an integer greater than 1.000.000 or less than -1.000.000 with at least with 50% probability.

Example outputs (all must be possible):
59875669123
12
-42
-4640055890
0
2014
12
24
-7190464664658648640055894646646586486400558904644646646586486400558904646649001

Clarifications:

A trailing line break is permitted.
Leading zeros aren't allowed.
-0 is permitted.

Shortest code wins.

Apart from noticing that your last example is way too long to fit in an integer, I think you should clarify that the program/function should have 50% probability of creating an integer within the bounds of -1.000.000 and +1.000.000 and outside as well.

I think the second rule should stop you from just outputting integers outside the range of +/-1.000.000 (100% > 50% so at least 50% is met)

@Optimizer I don't think so. The third rule makes it a real challenge as you need to define the probability for the integers on your own. If I generate 1000 integers, at least 500 of them have to be outside the range of +/-1.000.000. Normal implementations of random define all integers to have equal probability which is not asked for in the question.

@Optimizer Thats true the set is very small but the question asks for a change in probability. After thinking about the question it's obvious that the probability of generating an integer outside the range of +/-1.000.000 is more than 50%. Even more it's way more than 50% because the range of 2.000.000 integers in a set of 2^32 is about 0,04656612873077392578125% (checked with calculator). So the rest is the probability of integers outside that range, covering all the rules. (Shame on me noticing that so late)

Are we allowed to print leading zeros?

@Optimizer why are you assuming uniform probability? The question doesn't state it. In fact it seems clear from that point that the distribution doesn't have to be uniform as long as at least 50% of it falls outside of [-1 million, 1 million].

A solution that produces a "uniform distribution across all integers" is impossible.  There are infinitely many integers, so each individual integer would appear with a probability of 0.  (Or: Outputting a finite number would mean you are neglecting infinitely many others!)  Any solution will have to disfavour higher values in order to achieve P(total)=1.

@Ypnypn The computer's RAM isn't a limit, either. You don't have to store your partial output anywhere.

Many answers output leading zeros sometimes. Is that allowed?

@GiantTree - way too long to fit in an integer - This is only true if you assume that integer means the int datatype on a 32/64 bit arch, which is not necessarily a valid assumption. "Integer" started as a math term, which has no size constraints.

@user23013 Leading zeros aren't allowed. -0 is permitted.

@FakeName I know. My answer uses BigInt so I don't have that problem. In the beginning I haven't thought about that.

Anyone using a pseudo random number generator to make their decisions on the output will exclude almost all integers, and place an upper limit on the size of integers that can be produced (assuming that the PRNG has a finite period). Can this be disregarded in answers or does a valid answer require a true random number generator?

@githubphagocyte You can assume that the random number generator of your language is a true random number generator even if it isn't the case.

People have touched on this point before, but can you clarify the "any integer" rule?  Some integers in mathematics are too large for any computer that will ever exist to output digit by digit.  What is "any integer"?

@Muqo You're allowed to take infinite time to output infinite length answers.  You don't have to count the digits you output, or anything, so finite RAM and infinite time will suffice, as long as every possible integer could in theory be the output of your program, with the right sequence of return values from rand().

@Peter Cordes Ah, so integers are simply what the output looks like.  Really, this challenge is to output random digits on one line, not starting with 0, randomly stopping at some point while staying within the probability constraint.  Since RAM is finite, I would think any entry storing the whole output would be invalid.

@Muqo, yeah I'd agree that everyone who went with arbitrary precision instead of outputting a stream picked wrong, with exceptions for things like JavaScript where there isn't really an output destination that can accept a stream of unknown length.  And I guess it's interesting to see what people can do with toy languages for code-golfing, as long as the probability that they actually will use 4GB or something is vanishingly small.  A theoretical turing machine has an infinitely long tape, so just run it on that.  (if you can find an RNG on a turing machine :P)

function random() return 7; does this count?

CJam, 16 14 13 bytes
0{Kmr(+esmr}g

This will run for a very long time, because it uses the current timestamp (on the order of 1012) to determine if the loop should terminate. I'm using this as the submission, as it is the shortest, but there are two 14-byte alternatives, which have their own merits:
0{esmr(+esmr}g

This one is not limited by the period of the PRNG, since the range of all random numbers depends on the current timestamp. Therefore, this should be able to produce any number whatsoever, although the probability for negative, or even small positive numbers vanishingly small.
Below is an equivalent version that uses 3e5 instead of the timestamp. And 20 for the first range (as the 13-byte submission). It's much faster and also complies with all the rules. It is sort of the limiting case to get the 50% probability for numbers beyond 1,000,000 while keeping a reasonable runtime and small code-size. The explanation and mathematical justification refer to this version:
0{Kmr(+3e5mr}g

This usually takes a few seconds to run. You can replace the 5 with a 2 to make it run even faster. But then the requirement on the 50% probability will only be met for 1,000 instead of 1,000,000.
I'm starting at 0. Then I've got a loop, which I break out of with probability 1/(3*105). Within that loop I add a random integer between -1 and 18 (inclusive) to my running total. There is a finite (albeit small) probability that each integer will be output, with positive integers being much more likely than negative ones (I don't think you'll see a negative one in your lifetime). Breaking out with such a small probability, and incrementing most of the time (and adding much more than subtracting) ensures that we'll usually go beyond 1,000,000.
0              "Push a 0.";
 {          }g "Do while...";
  Kmr          "Get a random integer in 0..19.";
     (         "Decrement to give -1..18.";
      +        "Add.";
       3e5mr   "Get a random integer in 0..299,999. Aborts if this is 0.";

Some mathematical justification:

In each step we add 8.5 on average.
To get to 1,000,000 we need 117,647 of these steps.
The probability that we'll do less than this number of steps is
sum(n=0..117,646) (299,999/300,000)^n * 1/300,000

which evaluates to 0.324402. Hence, in about two thirds of the cases, we'll take more 117,647 steps, and easily each 1,000,000.
(Note that this is not the exact probability, because there will be some fluctuation about those average 8.5, but to get to 50%, we need to go well beyond 117,646 to about 210,000 steps.)
If in doubt, we can easily blow up the denominator of the termination probability, up to 9e9 without adding any bytes (but years of runtime).

...or 11 bytes?
Finally, there's an 11 byte version, which is also not limited by the period of the PRNG, but which will run out of memory pretty much every time. It only generates one random number (based on the timestamp) each iteration, and uses it both for incrementing and terminating. The results from each iteration remain on the stack and are only summed up at the end. Thanks to Dennis for this idea:
{esmr(}h]:+

I've added a comment to the question to see if the rules require a true random number generator, but I guessed you would appreciate the pedantry. Is your random source here pseudo random? That would restrict the size of the set of possible outputs to at most the period of your PRNG, right?

(+1 regardless for the simple elegance)

Yes I'm guessing all so far. I'm curious to see if someone posts an answer without that problem though...

I see the OP has stated that you can assume your random number generator is a true random number generator whether it is or not - so this is redundant now... :)

The sum of Kmr in a period is still likely always a big positive number larger than the period. And it can't produce every possible number in that case.

@MartinBüttner Oh, I was stupid and thought es to be something else for a while...

{esmr(}h]:+ saves two bytes.

@Dennis Haha, this is getting ridiculous, thanks!

Java, 133 149
void f(){String s=x(2)<1?"-":"";for(s+=x(9)+1;x(50)>0;s+=x(10));System.out.print(x(9)<1?0:s);}int x(int i){return new java.util.Random().nextInt(i);}

Example outputs
-8288612864831065123773
0
660850844164689214
-92190983694570102879284616600593698307556468079819964903404819
3264

Ungolfed
void f() {
    String s = x(2)<1 ? "-" : "";       // start with optional negative sign
    s+=x(9)+1;                          // add a random non-zero digit
    for(; x(50)>0; )                    // with a 98% probability...
        s+=x(10)                        // append a random digit
    System.out.print(x(9)<1 ? 0 : s);   // 10% chance of printing 0 instead
}

int x(int i) {
    return new java.util.Random().nextInt(i);
}

Old answer (before rule change)
void f(){if(Math.random()<.5)System.out.print('-');do System.out.print(new java.util.Random().nextInt(10));while(Math.random()>.02);}

Both of you are correct but the question states that the probability has to be at least 50% not in the range of +/-1.000.000

@Optimizer Redone.

If you use binary literals you don't have to print the -.

Mathematica - 47
Round@RandomVariate@NormalDistribution[0,15*^5]

Basically just generate random number using normal distribution with variance equal to 1500000. This will produce an integer between -10^6 and 10^6 with probability 49.5015%.

"This will produce an integer between -10^6 and 10^6 with probability 50.4985%." - that's not quite enough. Did you misread the spec? Perhaps you meant to use 10^7 as the variance?

@JanDvorak Wrong probability, sorry. Now it's the right one.

Does the implementation of this in Mathematica truly cover all integers? I don't have access to the source but I'd guess not...

@githubphagocyte It would depend on current precision.

Does Mathematica support arbitrary (unspecified) precision?

@githubphagocyte Yes, we can specify any precision. By default it's MachinePrecision.

What I mean is, specifying any specific precision will exclude numbers bigger than that. The only way it could work is if you could specify unlimited precision.

Python 2, 75 69 bytes
from random import*;s=0;j=randrange
while j(12):s=s*9+j(-8,9)
print s

It is trivial to check that the while loop in the middle can generate all integers (albeit biased towards zero). "12" is chosen such that there are roughly half of numbers exceeding ±106.

Older solution:
Python 2, 44 bytes
Based on the Mathematica solution.
from random import*;print int(gauss(0,8**7))

Doesn't really work because Python's float has only finite precision.

This won't be able to generate all integers, because the pseudo-random number generator has a finite amount of internal state.  According to the documentation Python uses the Mersenne Twister, so the state is quite large. But it is not infinite, so it can only produce a finite subset of all integers.

@starblue: From the OP: "You can assume that the random number generator of your language is a true random number generator even if it isn't the case."

Ruby, 70
f=->{m=10**6
r=rand -m..m
r<1?(r>-5e5??-:'')+r.to_s+f[][/\d+/]:r.to_s}

To make generating very large numbers possible, I'm returning the number as a String from a lambda. If that's not allowed, count 8 characters extra (for puts f[]) to make it a program instead of a function.
Explanation
Generate a number between -1,000,000 and 1,000,000. If the number is 1 or higher, the number is returned as a String.
If the number is lower than 1, the function is called recursively to return number outside the number range. To make sure negative numbers can also be generated, a - is prefixed to the resulting String if the initial number is greater than -500,000.
I hope I understood the challenge correctly!

R, 38
library(Rmpfr)
round(rnorm(1,2e6,1e6))

Draws from the Gaussian distribution with mean 2,000,000, chosen randomly, and standard deviation 1,000,000, so that about 2/3 of the draws will lie within 1,000,000 and 3,000,000. The distribution is unbounded so in theory this can generate any integer. The Rmpfr package replaces R's built in double floats with arbitrary precision.

Yeah I realized I misread the spec. And I imagine it has the same limitations on machine precision with Mathematica

Hmm in that case I'm not sure. I'll have to look into it; consider this answer "on hold" for now

@MartinBüttner fixed I think

Interesting. I don't think you need the whole sample(c(1,-1),1) think though. Just centering at 1e6 should be enough..

@MartinBüttner oh it doesn't need to be 50% at both ends? That wasn't clear

I meant jointly of course. Typing on a phone makes one lazy...

I don't understand? If one half has 50% and the other half has more than 0 (which it has, because each number must be possible), then they will have more than 50% jointly anyway, no?

Perl, 114 Chars
use Math::BigInt;sub r{$x=Math::BigInt->new(0);while(rand(99)!=0){$x->badd(rand(2**99)-2**98);}print($x->bstr());}

Breakdown:
use Math::BigInt;               -- include BigIntegers
  sub r{                        -- Define subroutine "r"
    $x=Math::BigInt->new(0);    -- Create BigInteger $x with initial value "0"
      while(rand(99)!=0){       -- Loop around until rand(99) equals "0" (may be a long time)
        $x->badd(               -- Add a value to that BigInt
          rand(2**99)-2**98);   -- Generate a random number between -2^98 and +2^98-1
        }print($x->bstr());}    -- print the value of the BigInt

The probability of getting a value between -1.000.000 and 1.000.000 are tending towards zero BUT it is possible.

Note: This subroutine may run for a long time and error out with an "Out of Memory!" error but it's technically generating any integer as stated in the question.

Perl, 25
sub r{rand(2**99)-2**98;}

Generates a random integer within the range of +/-2^99.
Breakdown
sub r{                    -- Define subroutine "r"
     rand(2**99)          -- Generate a random integer between 0 and 2^99
                -2**98;}  -- Subtract 2^98 to get negative values as well

Tested with 1 million samples:
~5 are inside the range of +/-1.000.000
~999.995 are outside that range
= a probability of ~99,99% of generating an integer outside that range.
Compare that number to the probability of 2.000.000 in 2^99: It is approx. the same.

This meets all rules:

1 integer
any integer is possible
at least 50% (in my case 99,99%) of all generated integers are outside the range of +/-1.000.000.

This works because the underlying random number generator defines equal probability to every bit that is generated, thus doing that on generated integers as well.  Every integer has a probability of 1/2^99 to be generated.

Edit:
I had to increase the exponent so that larger integers are being generated. I have chosen 99 because it keeps the code as short as possible.

Didn't we agree that there should not be any upper/lower bounds ? For instance, the integer 2^31 + 1 has 0 probability, breaking rule 2

@Optimizer for me an integer is defined as in many programming languages: a number within the bounds of -2^31 and +2^31-1 (32bits). You can easily increase the exponents if you'd like to generate larger integers but it may fail depending on the implementation of Perl.

I just saw that that ridiculously big integer has to be generated as well. I'll edit my code quickly.

@MartinBüttner I tried my best to meet the spec of the question. It's just not possible for me (at least not without help) to generate infinitely large integers. Perl's largest integer is about 1.7e308 which is a limit I cannot control.

@MartinBüttner Both are possible but eg. the string would overflow after 2gb of data making it finite again. It's hard to say that a number should be infinitely large if there are issues with memory. I'll come up with a different approach soon using BigInts.
Also the integer does not overflow at 1.7e308 it just gets converted to infite (1.#INF to be exact)

Hobbs and I both posted perl solutions that print a digit at a time.  (His prints leading zeros, mine doesn't).  This sidesteps and memory and BigInt problems.

Well, that's another way of doing it.

C#, 126 107  bytes
string F(){var a=new System.Random();var b=a.Next(-1E6,1E6+1)+"";while(a.Next(1)>0)b+=a.Next(10);return b;}

Ungolfed:
string F()
{
    System.Random rand = new System.Random();
    string rtn = rand.Next(-1E6, 1E6 + 1) + "";
    while (rand.Next(1) > 0)
         rtn += a.Next(10);
    return rtn;
}

Chance to generate a number of n digits is 1/2^(n-10), which is greater than 0 for all positive n, and 1/2 for n=11. Also creates leading zeros, which do not seem to be disallowed in the original question or any of its comments.

When using using System;, you don't need System.Random twice, but just Random, right?

@Charlie This is a function, so I can't use using statements. It would only save 1 char anyways.

You can save 1 char by removing the space at -1E6, 1E6+1.

Perl, 53 characters
print"-"if rand>.5;do{print int rand 10}while rand>.1

I certainly don't see any reason to work with integers when printing one :)
Has equal probability of printing a number with or without a leading "-".
Prints a 1-digit number 10% of the time, a 2-digit number 9% of the time, a 3-digit number 8.1% of the time, a 4-digit number 7.29% of the time, a 5-digit number 6.56% of the time, a 6-digit number 5.9% of the time, etc. Any length is possible, with decreasing probability. The one-through-five digit numbers account for about 41.5% of output cases, and the number 1,000,000 (or -1,000,000) only 6-millionths of a percent, so the output number will be outside of the range -1,000,000 through 1,000,000 about 54.6% of the time.
Both "0" and "-0" are possible outputs, which I hope is not a problem.

Doesn't this print "numbers" like -00000000167? That's not really an integer.

@isaacg I don't see why that is not an integer .

@Optimizer It is, but the OP has explicitly forbidden leading 0.

You could generate a random non-zero leading digit before the loop, from -9 to +9.  print int(rand(20)-10)||1.  I need a way to generate 0 as an output, though.  Maybe ||die 0, if the trailing garbage after the zero is allowed.  Else need a short way to print the zero and exit without further output if int(rand(20)-10)==0.

@PeterCordes agreed, that's a decent approach but I don't feel like writing it and I don't think it would be competitive length-wise. Feel free to submit it on your own :)

Your general idea is the same as I first thought of when I saw this problem: output digits as you generate them.  Much cleaner than these other solutions generating a BigInt in RAM.

posted my own answer

Perl, 62 bytes
print $n=int rand(20)-10;while($n&&rand>.1){print int rand 10}
I had the same idea as @Hobbs, of generating a digit at a time, but his code didn't satisfy the added no-leading-zeros requirement.  Generating the first digit instead of just the sign solved that.  And unless there's a shorter way to exit if we printed a zero, or a shorter way to generate the leading -9 to 9, this should do it for size.
In a shell loop: while perl -e '...'; do echo;done |less
I think this is one of the shortest that doesn't require infinite RAM to satisfy the problem.  As a bonus, the output is isn't strongly biased towards anything, and runtime is very fast.
I tried using bitwise and to save a character in the while condition, but I think this ends up being true more often, so the loop ends sooner.  Would need more chars to adjust other things to counter that, to maintain the probability of generating abs(output) > 1M.

Nice, you squeezed out some things that I wouldn't have thought of :)

Bash, 42 bytes
printf "%d\n" 0x$(xxd -p -l5 /dev/random)
/dev/random on OSX is just random bytes, and xxd -p -l5 converts 5 of the ascii characters to hex, and printf turns it into decimal format.

Javascript (73)
This solution uses that you can construct a number with base n by multiplying the previous number with n and adding a digit in base n. We have an additional ..?..:.. in there to be able to create all negative integers. The following code should be tested in a browser console.
b=Math.round;c=Math.random;x=0;while(b(c()*99)){x*=b(c())?2:-2;x+=b(c())}

The probability to get an integer >= 2^1 (or <= -(2^1)) is equal to the chance that the loop is ran 2 times. The chance of that happening is (98/99)^2. The chance of getting a number that is greater than 2^20 (or <= -(2^20)) is therefore (98/99)^21 = 0.808 or 81%. This is all in theory though, and assuming that Math.random is truely random. It obviously isn't.

Snippet testing this code. Also in a more readable fashion.

var interval = 0;
var epic_unicorns = 0;
var unicorns = 0;

function gimmerandom() {
  var b = Math.round;
  var c = Math.random;
  var x = 0;
  while( b(c()*99) ) {
    x *= b(c()) ? 2 : -2;
    x += b(c());
  }
  return x;
}

function randomcount() {
  var a = gimmerandom();
  if( a <= -1000000 || a >= 1000000 ) {
    epic_unicorns++;
  }
  unicorns++;
  updatedisplay();
}

function updatedisplay() {
  $('#num_of_epicunicorns').text( epic_unicorns );
  $('#num_of_unicorns').text( unicorns );
  var perc = unicorns > 0 ? Math.round( (epic_unicorns / unicorns) * 1000 ) / 10 : 0;
  $('#perc_of_unicorns').text( perc );
}

$('#a').on( 'click', function() {
  clearInterval( interval );
  interval = setInterval( randomcount, 10 );
} );

$('#b').on( 'click', function() {
  clearInterval( interval );
} );

$('#c').on( 'click', function() {
  epic_unicorns = 0;
  unicorns = 0;
  updatedisplay();
} );

updatedisplay();

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span id="num_of_epicunicorns"></span> / <span id="num_of_unicorns"></span> (<span id="perc_of_unicorns"></span>%) were larger than 1.000.000 or less than 1.000.000.

<br><br>
<input type="button" id="a" value="Start">
<input type="button" id="b" value="Stop">
<input type="button" id="c" value="Reset">

The OP has now confirmed that you can assume that your PRNG is truly random, even if it isn't.

GolfScript, 20 bytes
0{)8.?rand}do.2&(*4/

Yeah, this one is also kind of slow.
Compared to languages like CJam and Pyth, GolfScript suffers from a verbose random number generation keyword (rand).  To overcome this handicap, I needed to find a way to use it only once.
This code works by repeatedly picking a random number between 0 and 88−1 = 16,777,215 inclusive, and incrementing a counter until the random number happens to be 0.  The resulting counter value has a geometric distribution with a median approximately -1 / log2(1 − 1/88) ≈ 11,629,080, so it meets the "over 1,000,000 at least 50% of the time" test.
Alas, the random number thus generated is always strictly positive.  Thus, the extra .2&(*4/ part is needed to let it become negative or zero.  It works by extracting the second-lowest bit of the number (which is thus either 0 or 2), decrementing it to make it -1 or 1, multiplying it with the original number, and dividing the result by 4 (to get rid of the lowest two bits, which are now correlated with the sign, and also to allow the result to become zero).  Even after the division by 4, the absolute value of the random number still has a median of -1 / log2(1 − 1/88) / 4 ≈ 2,907,270, so it still passes the 50% test.

JavaScript, 81 bytes
This code fulfills all the rules:

Output any integer with positive probability
Output integers outside the range of +/-1000000 with at least 50% probability
No leading 0 in the output

As a bonus, the algorithm runs with a time complexity of O(log10n) so it returns the integer almost instantly.
for(s="",r=Math.random;r()>.1;s+=10*r()|0);r(s=s.replace(/^0*/,"")||0)<.5?"-"+s:s

This assumes an REPL environment. Try running the above code in your browser's console, or use the stack snippet below:

D.onclick = function() {
  for(s="", r=Math.random;r()>.1; s+=10*r()|0);
  P.innerHTML += (r(s=s.replace(/^0*/,"") || 0) <.5 ?"-" + s : s) + "<br>"
}
<button id=D>Generate a random number</button><pre id=P></pre>

Algorithm:

Keep appending random digits to string s until a Math.random() > 0.1.
Based on Math.random() > 0.5, make the number negative (by prepending the string s with -).

This algorithm does not have a uniform distribution across all integers. Integers with higher digit count are less probable than the lower ones. In each for loop iteration, there is a 10% chance that I will stop at the current digit. I just have to make sure that I stop after 6 digits more than 50% of the time.
This equation by @nutki explains the maximum value of stopping chance percentage based on the above condition:
1 - 50%^(1/6) ≈ 0.11

Thus 0.1 is well within range to satisfy all the three rules of the question.

There are a few things that confuse me about this answer. Have you assumed that Math.random() generates a uniform distribution of random numbers, because the spec states that it is implementation dependent. Assuming that it is a uniform distribution, P(Math.random()>0.1)=0.9 so there is a huge probability that it will terminate between each iteration. An implementation of your algorithm run on Firefox 34.0 Ubuntu gives me a probability of ~0.47 (<0.5) every time that I test it: http://jsfiddle.net/WK_of_Angmar/dh8gq4pb/

Also, how have you managed to calculate a time complexity for an algorithm without an input?

TI-BASIC, 14 bytes
1-2int(2rand:randNorm(AnsE6,9

Similar to @ssdecontrol's R answer, this draws from the Gaussian distribution with mean -1,000,000 or 1,000,000, chosen randomly, and standard deviation 9. The distribution is unbounded so in theory this can generate any integer.
Explanation:
1-2int(2rand     - get a random integer 0 or 1, then multiply by 2 and subtract 1
:                - this gives the number 1 or -1 (with equal probability) to Ans
randNorm(AnsE6,9 - displays Gaussian distribution with mean (Ans * 1,000,000) and std. dev. 9

But can it generate "2" or "-2"?

Yes, obviously. http://tibasicdev.wikidot.com/randnorm

OK read the code wrongly (thought : means "print" due to how the explanation is presented). But can it generate numbers more than 20 digits?

Any arbitrary long integer is possible as an output ? Isn't this limited by the range of randNorm ?

"The distribution is unbounded so in theory this can generate any integer." There is no range.

This can't generate numbers with absolute value >10^100 because you can't store such numbers.

Bash, 66
LANG=C sed -r '/^-?(0|[1-9][0-9]*)$/q;s/.*/5000000/;q'</dev/random

It almost always prints 5000000. But if it found a valid number in /dev/random, it will print that number instead.
And this one is faster:
LANG=C sed -r '/^-?(0|[1-9][0-9]*)$/q;s/.*/5000000/;q'</dev/urandom

@Optimizer It is supposed to be slow. That's because it is a real random source. But you can test it with /dev/urandom which is less random.

@Optimizer How would that be taking manual input? It's reading a file, but everything's a file.

@Optimizer I simply don't understand the point you're going for.

reading from /dev/urandom in a shell script is basically the same as calling rand() in other languages.  Although if you're really using bash, not POSIX sh, you can get random numbers from echo $RANDOM.  https://wiki.ubuntu.com/DashAsBinSh gives hexdump /dev/urandom as an equivalent for bare-POSIX-minimum /bin/dash.

hexdump /dev/random|head|tr -cd '[0-9]' spits out a 240+ byte integer :)

shuf -i0-9 -r|tr -d \\n will fill up your terminal...

C++, 95 bytes
void f(){int d=-18,s=-1;while(s<9){d=(rand()%19+d+9)%10;cout<<d;s=9-rand()%10*min(d*d+s+1,1);}}

Expanded:
void f() {
    int d=-18,s=-1;
    while(s<9) {
        d=(rand()%19+d+9)%10;
        cout<<d;
        s=9-rand()%10*min(d*d+s+1,1);
    }
}

Explanation:
The function keeps on printing consecutive random digits until a random valued switch takes the required value to stop the function. d is the variable that keeps the value of the next digit to be printed. s is the switch variable that takes random integer values in the interval [0, 9], if s == 9 then no more digits are printed and the funtion ends.
The variables d and s are initialized in order to give special treatment to the first digit (taking it from the interval [-9, 9] and if the first digit is zero then the function must end to avoid leading zeroes). The value of d could be assigned as d=rand()%10 but then the first digit couldn't be negative. d is assigned instead as d=(rand()%19+d+9)%10 and initialized at -18 so the first value of d will range from [-9, 9] and the next values will always range from [0, 9].
The variable s ranges randomly from [0, 9], and if s equals 9, the function ends, so after printing the first digit the next one will be printed with a probability of 90% (assuming rand() is truly random, and in order to satisfy the third condition). s could be easily assigned as s=rand()%10, however, there is an exception, if the first digit is zero, the function must end. In order to handle such exception, s has been assigned as s=9-rand()%10*min(d*d+s+1,1) and initialized as -1. If the first digit is zero, the min will return 0 and s will equal to 9-0=9. s variable's assignment will always range from [0, 9], so the exception can only occur at the first digit.
Characteristics (assuming rand() is truly random)

The integer is printed digit by digit, with a fixed probability of 90% of printing another digit after printing the last one.
0 is the integer with highest chance of being printed, with a probability of aproximately 5.2%.
The probability of printing an integer on the interval [-10^6, 10^6] is aproximately 44% (the calculation is not written here).
Positive and negative integers are printed with the same probability (~47.4%).
Not all digits are printed with the same probability. For example: in the middle of printing the integer, if the last digit was 5, the digit 3 will have a slightly lower chance of being printed next. In general, if the last digit was d, the digit (d+18)%10 will have a slightly lower chance of being printed next.

Example outputs (10 executions)
-548856139437
7358950092214
507
912709491283845942316784
-68
-6
-87614261
0
-5139524
7

Process returned 0 (0x0)   execution time : 0.928 s
Press any key to continue.

Java (JDK), 140 127 bytes
()->{int i;var o=System.out;for(o.print(i=(int)(19*Math.random())-10);i!=0&Math.random()<.9;)o.print((int)(11*Math.random()));}

-13 bytes by sneaking more logic into the loop header - thanks to @ceilingcat
Try it online!

BSD jot, 17 bytes
jot -r 1 -9e9 9e9

Try it Online! The above code works correctly on MacOS (and presumably BSD), but TIO (and ATO) do not have the same jot as I do. Link is to a truncated version that only generates positive integers.

This worked so it can output negative integers on TIO

Cool, but that's another 3 whole bytes! :-o

so we had to note the command must be BSD's

Pyth, 11 bytes
WOyG~ZtOT)Z

Note: this program will probably crash with a memory error on any real computer. To test it, try replacing G with a shorter string, such as in this code, which generates numbers averaging around 28000:
pyth -c 'WOy"abcdefghijklm"~ZtOUT)Z'

This code loops, adding a random number from -1 to 8 to Z, with a 2^-26 probability of exiting the loop on each repetition. The 2^-26 probability is attained by selecting a random element (O) of the set of all subsets (y) of the alphabet (G).
Technical details & justification:
The probability 2^-26 is derived from two facts: y, when called on sequences, is the power-set function, an constructs the list of all subsets of the input. Since the input, G, is 26 characters long, this power-set, yG has 2^26 entries. OyG selects a random element from those 2^26 entries. Exactly one of those entries, the empty string, will evaluate as falsy when passed to W, the while loop. Therefore, there is a 2^-26 probability of exiting the loop each time.
In any fixed number of loop cycles K, the probability of getting the number K*3.5 + m and getting K*3.5 - m are equal, because each sequences of addends that achieves one total can be inverted, -1 -> 8, 0 -> 7, etc., to achieve the other. Additionally, numbers closer to K*3.5 are clearly more likely than numbers farther away. Thus, if K > 2000000/3.5 = 571428.5 the probability of getting a number over 1000000 is greater than 75%, because some of the results above that number can be put into a one-to-one correspondence with all of the results below that number, and the upper less-than-half, can be put into a one-to-one correspondence with those under 1000000. The probability of getting at least 571429 loops is (1-2^-26)^571429, which is no less than (1-2^-26 * 571429), the expected number of times leaving the loop over the first 571429 tries, which is 99.1%. Thus, on 99.1% or more of trials, there is a 75% or more chance of getting at least 1000000, so there is more than a 50% chance of getting over 1000000.
This code relies on a behavior of O where a bug was accidentally introduced 3 days ago and was fixed today. It should work on any version of Pyth 3 from before Dec 22nd, or after today. The following code is equivalent, and has always worked:
WOyG~ZtOUT)Z

What happened to the online compiler ?

@Optimizer Issues with the website, I'll work on it.

Ah.. cool. Wanted to work on the Pyth translation of my CJam answer yesterday and found that it gives 404.

Java, 113 bytes
void g(){String a=Math.random()>0?"10":"01";for(;Math.random()>0;)a+=(int)(Math.random()*2);System.out.print(a);}

This program prints a binary number to standard output stream. You might have to wait a while because the probability of it ending the number (or it being positive) is approximately 0. The idea that the absolute value of a number generated is less than 1 million is amusing, yet possible.
Ungolfed:
void g(){
    String a=Math.random()>0?"10":"01";             //Make sure there are no trailing zeroes.
    for(;Math.random()>0;)a+=(int)(Math.random()*2);//Add digits
    System.out.print(a);                            //Print
}

Sample output: Will post when a number is done being generated.


text:
String generator based on a wildcard
Your task, if you accept it, is to make a string generator that generates strings based on a wildcard.
You can make a function or a full program that receives 1 argument and sends to the standard output/console a string that matches.
Wildcard characters and sequences:

* produces 0 or more random characters
? produces exactly 1 random character
[] detonates a group and produces any one of the characters from the group, exactly once.
[]* produces at least 0 of the characters from that group
[]? produces any one of the characters from that group, at most once
[]{n} produces n characters in that group
Anything else is a literal string

The supported characters to return are a-z, A-Z and 0-9.
Casing doesn't matter.
You can do whatever you want with invalid input.
Examples:
f('a[d-f]{3}') //return 'addd', 'adde', 'addf' ...

f('a*') //returns 'a' or anything starting with 'a'

f('[bt]est') //returns 'best', 'test'

Scoring:

Shortest code in bytes wins.
-10% bonus if you support symbols
-10% bonus if you implement multiple matches, inside each group (e.g.: [ae,c-d,0-5])
-20% bonus if you implement negated group (e.g.: [^a-f] returns anything that doesn't start with a-f)
-10% if you support at least 3 regex character classes (e.g.: \d,\s,\D)
Standard loopholes are not allowed!

Any doubts, feel free to ask in a comment.

Can groups be nested? ("a[[d-f]?g]*")

@BMac No, that would be too complicated to parse. I wanted to keep this as simple as possible, but I already over-complicated it. You can implement it (since it is considered invalid output, you do what you want) if you want. But it won't have any benefit for you. Unless people upvote your answer for implementing on that way, then you would get reputation.

Python 3, 511 bytes - 10% = 459.9
It's early morning over here so golfing mode hasn't quite kicked into my system yet, but it was a really fun-looking problem so I thought I'd try it anyway.
from random import*
C=0
r=input()
i=0
S=""
Q=""
while i<len(r):
 c=r[i]
 if i<len(r)-1:d=r[i+1]
 if"]"==c:
  C=0
  if d not in"*?{":S+=choice(Q)
 elif"["==c:C=1;Q=""
 elif"*"==c:
  while random()>.2:S+=choice(Q)
 elif"?"==c:S+=choice(Q)*randint(0,1)
 elif"{"==c:
  a=""
  while r[i+1]!="}":a+=r[i+1];i+=1
  S+="".join(choice(Q)for _ in range(int(a)))
 elif"}"!=c:
  if"-"==d:Q+="".join(chr(x)for x in range(ord(c),ord(r[i+2])+1));i+=2
  else:
   Q=C*Q+c
   if not C and d not in"*?{":S+=choice(Q)
 i+=1
print(S)

I'm claiming the "multiple matches, inside each group" bonus. You can try it out like so:
[abA-C0]*

Your code looks nice! The negated group should be trivial to implement. Same for the classes. But be careful with the classes, since they have to always return valid results.


text:
Nearest partition numbers
The number of partitions of an integer is the number of ways that integer can be represented as a sum of positive integers.
For example:
5
4 + 1
3 + 2
3 + 1 + 1
2 + 2 + 1
2 + 1 + 1 + 1
1 + 1 + 1 + 1 + 1

There are 7 ways to represent the number 5, therefore 7 is the partition number corresponding to the number 5.
Partition numbers: OEIS: #A000041
Directions
Write a program that takes a positive integer as input, and outputs the two numbers that generate the two closest partition numbers to the input number.

Input must be 1 positive integer.
If the input is not a partition number, the output must be the 2 different positive integers that generate the two closest partition numbers to the input number. (If two partition numbers are equal candidates for one of the output numbers, it doesn't matter which one you choose.)
If the input is a partition number, the output must be 1 positive integer that generates the input number.
Input and output may be in any reasonable format.
You may assume that the input will not be larger than 100 million (eg. output will never be larger than 95).
Built-in functions to calculate partition numbers are not allowed, along with other Standard loopholes.
This is code-golf, so least number of bytes wins.

Partition numbers: OEIS: #A000041
Examples
Input: 66
Output: 11, 12

(The partition numbers that correspond to the numbers 11 and 12 are 56 and 77, which are the two closest partition numbers to 66.)
Input: 42
Output: 10

(The number 42 is already a partition number, so just output the number that corresponds to the partition number.)
Input: 136
Output: 13, 14

(The two closest partition numbers to 136 are actually both LESS than 136 (eg. 101 and 135), therefore the output is 13 and 14 as opposed to 14 and 15.)
Input: 1
Output: 0   or   1

(Both 0 and 1 are valid outputs in this special case.)
Input: 2484
Output: 26, 25   or   26, 27

(Both of these outputs are valid, because 2484 is equal distance from 1958 and 3010.)
Input: 4
Output: 3, 4

(Yup)

You didn't define what is a partition number

@proudhaskeller Partition numbers are the numbers that are in the OEIS sequence linked. Explanation for what the partition number for 5 is is at the top. (I'll add clarification if you think it's not clear enough.)

This is very close to being a dupe of this earlier partition question.

Pyth, 53
L?!b<b1sm&d*^_1tdy-b/*dt*3d2r_bhbJo^-QyN2U99<J-2qQyhJ

Explanation and more golfing to follow.

Python 2, 179 bytes
Z=range(1,99)
R=Z+[1]
for i in Z:R[i]=sum(-(-1)**k*(3*k*k-k<=i*2and R[i-k*(3*k-1)/2])for k in range(-i,i+1)if k)
f=lambda n:zip(*sorted((abs(n-R[i]),i)for i in Z))[1][:2-(n in R)]

Uses the recursive formula from Euler's pentagonal theorem.
Call with f(2484). Output is a tuple with one or two numbers.

Mathematica, 124 123 bytes
f@n_:=(p=SeriesCoefficient[1/Product[1-x^k,{k,#}],{x,0,#}]&;s=SortBy[Range@95,Abs[n-p@#]&];If[p@s[[1]]==n,s[[1]],s~Take~2])

Formula for partition numbers taken from the OEIS page. (May or may not be cheating... I couldn't decide.)
Usage:
In: f[136]

Out: {14, 13}

I'm not answering to win. And I'm sure this could be golfed further.

Jelly, 17 bytes
eⱮRŒṗẈrƝƲTµ;‘ṁ3ḊQ

Try it online!
Outputs in reverse order.
I think this just about follows the rule "Built-in functions to calculate partition numbers are not allowed", as this uses the Jelly builtin to calculate the list of integer partitions, not the number of partitions. For example, 4Œṗ => [[1, 1, 1, 1], [1, 1, 2], [1, 3], [2, 2], [4]].
How it works
eⱮRŒṗẈrƝƲTµ;‘ṁ3ḊQ - Main link. Takes an input n on the left
        Ʋ         - Group the previous 4 links together:
  R               -   Take the range 1...n
   Œṗ             -   Calculate the partitions of each k in the range
     Ẉ            -   Take the length of each.
                  -   This gives the kth partition number
      rƝ          -   Insert ranges for each overlapping pair of partition numbers
 Ɱ                - For each of the list of ranges...
e                 -   Yield 1 if n is in the range between the kth and (k+1)th partition number and 0 otherwise
         T        - Remove 0s and replace 1s with their index
                  - For partition numbers, this yields two values. If m is the desired output, this yields [m-1, m]
                  - For non-partition numbers, this returns [m], when the required output is [m, m+1]
          µ       - Set the return value to either U = [m-1, m] or U = [m]
            ‘     - Yield [m, m+1] or [m+1]
           ;      - Concatenate to U, giving either [m-1, m, m, m+1] or [m, m+1]
             ṁ3   - Mold to length 3, giving either [m-1, m, m] or [m, m+1, m]
               Ḋ  - Remove the first value, returns [m, m] or [m+1, m]
                Q - Remove duplicates and output either [m] or [m+1, m]