text:
Simulate a Rubik's cube
A Rubik's cube has 6 colors: red, orange, yellow, white, blue, and green. Red and orange, yellow and white, and blue and green faces are on opposite sides.
Net of a solved Rubik's cube looks like this:
 Y
BRGO
 W

And the tiles look like this:
      Y Y Y
      Y Y Y
      Y Y Y
B B B R R R G G G O O O
B B B R R R G G G O O O
B B B R R R G G G O O O
      W W W
      W W W
      W W W

Challenge
Given rotations, reversed rotations, or double rotations output what a solved cube will transform to, as ASCII art or as an image (whitespaces aren't necessary, may or may not exist, trailing whitespaces are allowed.).
Input will be rotation (and optional modifier). Rotation notation goes like: U(p), L(eft), F(ront), R(ight), B(ack), D(own); 2 (double), ' or i (inverse).
All normal rotations will be 90° clockwise, inverse ones will be counterclockwise.
Explanation about clockwiseness: Imagine the cube as you're looking at the red face, and the yellow face is at the top. Then rotate the cube so that the face that the program will rotate will face you. This is the way clockwiseness will work. (Except back face, you will rotate the cube horizontally in that case.)
Input
Input will be a list of moves.
Output
An ASCII art that represents the cube or an image of the net of the cube.
Examples
Input:  (empty)
Output:
      Y Y Y
      Y Y Y
      Y Y Y
B B B R R R G G G O O O
B B B R R R G G G O O O
B B B R R R G G G O O O
      W W W
      W W W
      W W W

Input: U (up)
Output:
      Y Y Y
      Y Y Y
      Y Y Y
R R R G G G O O O B B B
B B B R R R G G G O O O
B B B R R R G G G O O O
      W W W
      W W W
      W W W

Input: U' or Ui (inverse up)
Output:
      Y Y Y
      Y Y Y
      Y Y Y
O O O B B B R R R G G G
B B B R R R G G G O O O
B B B R R R G G G O O O
      W W W
      W W W
      W W W

Input: U2 (double up)
Output:
      Y Y Y
      Y Y Y
      Y Y Y
G G G O O O B B B R R R
B B B R R R G G G O O O
B B B R R R G G G O O O
      W W W
      W W W
      W W W

Input: L' (inversed left)
Output:
      R Y Y
      R Y Y
      R Y Y
B B B W R R G G G O O Y
B B B W R R G G G O O Y
B B B W R R G G G O O Y
      O W W
      O W W
      O W W

Input: R (right)
Output:
      Y Y R
      Y Y R
      Y Y R
B B B R R W G G G Y O O
B B B R R W G G G Y O O
B B B R R W G G G Y O O
      W W O
      W W O
      W W O

Input: U2 L' D (double up, inverse left, down)
Output:
      O Y Y
      R Y Y
      R Y Y
G B B W O O B B B R R Y
G B B W R R G G G O O Y
O O Y G B B W R R G G G
      R O O
      W W W
      W W W

Rules

No loopholes allowed.
This is code-golf, so shortest code in bytes solving the problem wins.

Related, related, related.

May we choose to choose to re-orient the cube (for example, having White U, Orange F, and Green R)?

Yes, of course, as long as they're separate and recognizable.

Do we need to support S, E, M, x, y, z, u/Uw, d/Dw, r/Rw, l/Lw, f/Fw, b/Bw moves as well? Or only the default: U, D, R, L, F, B and their counterclockwise variant with apostrophe (')? Off-topic: I always wonder with Rubik's Cube related questions, are you also a Twisty Puzzles collector?

No, just the 6 standard default moves, counterclockwise variants and 180° variants (like U2). Also no, I'm not a collector.

@KevinCruijssen Dang, that's a lot of puzzles.

@mbomb007 Thanks! :) Funny that you took the effort to look them up in my profile. ;p (For anyone else wondering now: my Twisty Puzzles collection - the collection pictures are actually from a few months ago, I now have one more shelve, which is full again... Really need to make some new pictures, but still have a few puzzles scrambled after my scramble video in February.. Once and never again.. >.>)

Can we have a more lax output format and allow this sort of output?

@MDXF sure, i can't see a reason why not

Ruby, 370 339 305 bytes
Latest edit: a few bytes saved by rearrangement of the plotting formulas and removal of unnecessary brackets. A massive saving by rewriting the generation of the cube - I never knew Ruby had a builtin for Cartesian Products!
->s{q=[-66,0,71].product [-87,0,89],[-79,0,82]
s.map{|c|m="LDBRUF".index c[0];e=m/3*2-1
c.sub(/[i']/,"33").chars{q.map{|j|j[m%=3]*e>0&&(j[m-2],j[m-1]=j[m-1]*e,-j[m-2]*e)}}}
t=[" "*12]*9*$/
q.map{|r|a,b,c=r.map{|i|i<=>0}
3.times{|i|r[i]!=0&&t[56+[a*3-a*c-d=b*13,a-d*3+d*c,3-d-c*3+c*a][i]]=r[i].abs.chr}}
t}

Anonymous function.
Accepts an array of strings, each representing one face turn (a single string with spaces between each face turn is an additional 6 bytes.)
Returns a 9x12 rectangular string.
Brief explanation
This is closely based on a concept from my answer to this question, which in turn was based on a similar concept by Jan Dvorak.
The first line generates a 27 element array, representing the 27 cubies. Each cubie is represented by a 3 dimensional vector in which the sign represents its current position and the magnitude of each coordinate represents the ascii code for the colour of the sticker.
Example move: for R, for each cubie check if the x coordinate is >0 and if so rotate 90 degrees by swapping the y and z coordinates and swapping the sign of one of them.
Take a 9x12 array of spaces and plot the cube into it. For each cubie and axis we check if the sticker exists (coordinate in that axis nonzero), and work out where it is to go. Then we take the coordinate and perform .abs.chr to change the number into the required character and plot it.
Ungolfed in test program (per 339 byte edit)
f=->s{

  q=(0..26).map{|i|                         #Build an array of 27 cubies
    [[-66,0,71][i%3],                       #x coordinate B.G
     [-87,0,89][i/3%3],                     #y coordinate Y.W
     [-79,0,82][i/9]]                       #z coordinate O.R
  }

  s.map{|c|                                 #For each move in the input array
    m="LDBRUF".index(c[0]);e=m/3*2-1        #m=face to move. e=-1 for LDB, +1 for RUF.
    c.sub(/[i']/,"33").chars{               #Substitute "i" and "'" for "33" so chars in string = clockwise 1/4 turns required. For each char...
      q.map{|j|j[m%=3]*e>0&&                #...and each cubie, m%3 tells the relevant axis. if coordinate*e>1 rotate the cubie 1/4 turn.
        (j[m-2],j[m-1]=j[m-1]*e,-j[m-2]*e)} #Swap other two axes and change sign of one. e performs sign change if necessary for LDB.
    }
  }

  t=[" "*12]*9*$/                           #Make an array of 9 strings of 12 spaces, then make a single string by joining them with newlines
  q.map{|r|                                 #For each cubie
    a,b,c=r.map{|i|i<=>0}                   #make a normalised (-1,0,1) copy of each coordinate.
    d=b*13                                  #13 chars per line, d will be useful for plotting to the correct line of the output.
    3.times{|i|                             #For each of the 3 coordinates of the cubie
      r[i]!=0&&                             #if zero, sticker doesn't exist (edges and centres have <3 stickers.) If not zero plot the sticker.
      t[[56-d+a*3-a*c,                      #Calculate position on plot for x (L/R faces),
         56-d*3+d*c+a,                      #Calculate position on plot for y (D/U faces),
         59-d-c*3+c*a][i]]=                 #Calculate position on plot for z (B/F faces). Select the correct axis.
      r[i].abs.chr                          #Convert the coordinate to a character and assign to the correct space on the output plot.
    }
  }
t}                                          #Return the output string.

puts f[gets.chomp.split]

Output
Checkerboard
U2 D2 F2 B2 L2 R2
   YWY
   WYW
   YWY
BGBRORGBGORO
GBGOROBGBROR
BGBRORGBGORO
   WYW
   YWY
   WYW

6-spot
U D' R L' F B' U D'
   RRR
   RYR
   RRR
WWWGGGYYYBBB
WBWGRGYGYBOB
WWWGGGYYYBBB
   OOO
   OWO
   OOO

Testcase
U2 L' D
   OYY
   RYY
   RYY
GBBWOOBBBRRY
GBBWRRGGGOOY
OOYGBBWRRGGG
   ROO
   WWW
   WWW

C, 1715 1709 1686 1336 1328 bytes
25 bytes saved thanks to @KevinCruijssen!
No answers so far, so I decided to put my own solution.
#define m(a,b,c,d)t[c][d]=r[a][b];
#define n(a)m(a,0,a,2)m(a,1,a,5)m(a,2,a,8)m(a,3,a,1)m(a,5,a,7)m(a,6,a,0)m(a,7,a,3)m(a,8,a,6)
#define y memcpy
typedef char R[6][9];R t;F(R r){y(t,r,54);n(0)m(4,6,1,0)m(4,7,1,3)m(4,8,1,6)m(1,0,5,0)m(1,3,5,1)m(1,6,5,2)m(5,0,3,2)m(5,1,3,5)m(5,2,3,8)m(3,2,4,6)m(3,5,4,7)m(3,8,4,8)y(r,t,54);}B(R r){y(t,r,54);n(2)m(1,2,4,0)m(1,5,4,1)m(1,8,4,2)m(3,0,5,6)m(3,3,5,7)m(3,6,5,8)m(4,0,3,6)m(4,1,3,3)m(4,2,3,0)m(5,6,1,8)m(5,7,1,5)m(5,8,1,2)y(r,t,54);}L(R r){y(t,r,54);n(3)m(0,0,5,0)m(0,3,5,3)m(0,6,5,6)m(2,2,4,6)m(2,5,4,3)m(2,8,4,0)m(4,0,0,0)m(4,3,0,3)m(4,6,0,6)m(5,0,2,8)m(5,3,2,5)m(5,6,2,2)y(r,t,54);}E(R r){y(t,r,54);n(1)m(0,2,4,2)m(0,5,4,5)m(0,8,4,8)m(5,2,0,2)m(5,5,0,5)m(5,8,0,8)m(4,2,2,6)m(4,5,2,3)m(4,8,2,0)m(2,0,5,8)m(2,3,5,5)m(2,6,5,2)y(r,t,54);}U(R r){y(t,r,54);n(4)m(0,0,3,0)m(0,1,3,1)m(0,2,3,2)m(1,0,0,0)m(1,1,0,1)m(1,2,0,2)m(2,0,1,0)m(2,1,1,1)m(2,2,1,2)m(3,0,2,0)m(3,1,2,1)m(3,2,2,2)y(r,t,54);}D(R r){y(t,r,54);n(5)m(0,6,1,6)m(0,7,1,7)m(0,8,1,8)m(1,6,2,6)m(1,7,2,7)m(1,8,2,8)m(2,6,3,6)m(2,7,3,7)m(2,8,3,8)m(3,6,0,6)m(3,7,0,7)m(3,8,0,8)y(r,t,54);}a,b,c,d,e,o,p,l;f(char*z,R s){char c[6]="RGOBYW";for(;b<7;b++)for(a=0;a<10;)s[b][a++]=c[b];for(l=strlen(z);l-->0;){d=*z++;if(d-32){e=*z++;if(*z++-32)*z++;o=e-50?e-39?1:3:2;for(p=0;p++<o;)d-70?d-66?d-76?d-82?d-85?D(s):U(s):E(s):L(s):B(s):F(s);}}}

Try it online!
Ungolfed old version:
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>

typedef char Tile;
typedef Tile Face[10];
typedef Face Rubik[7];

void main_loop(Rubik);
void rubik_init(Rubik);
void rubik_print(Rubik);
void rotate(Rubik, char, char);
void print_tile(Rubik, int, int);

void F(Rubik);
void B(Rubik);
void L(Rubik);
void R(Rubik);
void U(Rubik);
void D(Rubik);

#define move(a, b, c, d) \
      temp[c][d] = rubik[a][b]

#define move_f(a) \
    move(a, 1, a, 3); \
    move(a, 2, a, 6); \
    move(a, 3, a, 9); \
    move(a, 4, a, 2); \
    move(a, 6, a, 8); \
    move(a, 7, a, 1); \
    move(a, 8, a, 4); \
    move(a, 9, a, 7)

void F(Rubik rubik) {
    Rubik temp;
    memcpy(temp, rubik, sizeof(Rubik));
    move_f(1);
    move(5, 7, 2, 1);
    move(5, 8, 2, 4);
    move(5, 9, 2, 7);
    move(2, 1, 6, 1);
    move(2, 4, 6, 2);
    move(2, 7, 6, 3);
    move(6, 1, 4, 3);
    move(6, 2, 4, 6);
    move(6, 3, 4, 9);
    move(4, 3, 5, 7);
    move(4, 6, 5, 8);
    move(4, 9, 5, 9);
    memcpy(rubik, temp, sizeof(Rubik));
}

void B(Rubik rubik) {
    Rubik temp;
    memcpy(temp, rubik, sizeof(Rubik));
    move_f(3);
    move(2, 3, 5, 1);
    move(2, 6, 5, 2);
    move(2, 9, 5, 3);
    move(4, 1, 6, 7);
    move(4, 4, 6, 8);
    move(4, 7, 6, 9);
    move(5, 1, 4, 7);
    move(5, 2, 4, 4);
    move(5, 3, 4, 1);
    move(6, 7, 2, 9);
    move(6, 8, 2, 6);
    move(6, 9, 2, 3);
    memcpy(rubik, temp, sizeof(Rubik));
}

void L(Rubik rubik) {
    Rubik temp;
    memcpy(temp, rubik, sizeof(Rubik));
    move_f(4);
    move(1, 1, 6, 1);
    move(1, 4, 6, 4);
    move(1, 7, 6, 7);
    move(3, 3, 5, 7);
    move(3, 6, 5, 4);
    move(3, 9, 5, 1);
    move(5, 1, 1, 1);
    move(5, 4, 1, 4);
    move(5, 7, 1, 7);
    move(6, 1, 3, 9);
    move(6, 4, 3, 6);
    move(6, 7, 3, 3);
    memcpy(rubik, temp, sizeof(Rubik));
}

void R(Rubik rubik) {
    Rubik temp;
    memcpy(temp, rubik, sizeof(Rubik));
    move_f(2);
    move(1, 3, 5, 3);
    move(1, 6, 5, 6);
    move(1, 9, 5, 9);
    move(6, 3, 1, 3);
    move(6, 6, 1, 6);
    move(6, 9, 1, 9);
    move(5, 3, 3, 7);
    move(5, 6, 3, 4);
    move(5, 9, 3, 1);
    move(3, 1, 6, 9);
    move(3, 4, 6, 6);
    move(3, 7, 6, 3);
    memcpy(rubik, temp, sizeof(Rubik));
}

void U(Rubik rubik) {
    Rubik temp;
    memcpy(temp, rubik, sizeof(Rubik));
    move_f(5);
    move(1, 1, 4, 1);
    move(1, 2, 4, 2);
    move(1, 3, 4, 3);
    move(2, 1, 1, 1);
    move(2, 2, 1, 2);
    move(2, 3, 1, 3);
    move(3, 1, 2, 1);
    move(3, 2, 2, 2);
    move(3, 3, 2, 3);
    move(4, 1, 3, 1);
    move(4, 2, 3, 2);
    move(4, 3, 3, 3);
    memcpy(rubik, temp, sizeof(Rubik));
}

void D(Rubik rubik) {
    Rubik temp;
    memcpy(temp, rubik, sizeof(Rubik));
    move_f(6);
    move(1, 7, 2, 7);
    move(1, 8, 2, 8);
    move(1, 9, 2, 9);
    move(2, 7, 3, 7);
    move(2, 8, 3, 8);
    move(2, 9, 3, 9);
    move(3, 7, 4, 7);
    move(3, 8, 4, 8);
    move(3, 9, 4, 9);
    move(4, 7, 1, 7);
    move(4, 8, 1, 8);
    move(4, 9, 1, 9);
    memcpy(rubik, temp, sizeof(Rubik));
}

int main(int argc, char *argv[]) {
    Rubik rubik;
    rubik_init(rubik);
    main_loop(rubik);
    return 0;
}

void main_loop(Rubik rubik) {
    char a, b;
    for (;;) {
        a=toupper(getchar());
        if (a == 'Q') break;
        if (a != 10) {
            b=toupper(getchar());
            if (b != 10) getchar();
            rotate(rubik, a, b);
        }
        rubik_print(rubik);
    }
}

void rubik_init(Rubik rubik) {
    int i,n;
    char c[7] = " RGOBYW";

    for (n=1; n<=7; n++)
        for (i=1; i<=10; i++)
            rubik[n][i] = c[n];
}

void rotate(Rubik rubik, char a, char b){
    int i = b == '2' ? 2 : b == '\'' || b == toupper('i') ? 3 : 1;
    int j;
    for (j=0; j<i; j++)
        if (a == 'F') F(rubik);
        else if (a == 'B') B(rubik);
        else if (a == 'L') L(rubik);
        else if (a == 'R') R(rubik);
        else if (a == 'U') U(rubik);
        else if (a == 'D') D(rubik);
        else;
}

void rubik_print(Rubik rubik) {
    int i,j,k;

    for (i=1; i<=9; i++)
        if (i%3==0) {
            print_tile(rubik,5,i);
            printf("\n");
        }
        else if (i%3==1) {
            printf("    ");
            print_tile(rubik,5,i);
        }
        else
            print_tile(rubik,5,i);

    printf("\n");

    for (k=1; k<=3; k++) {
        for (i=3; i<=6; i++) {
            for (j=k*3-2; j<=k*3; j++)
                print_tile(rubik, i%4+1, j);
            printf(" ");
        }
        printf("\n");
    }

    printf("\n");

    for (i=1; i<=9; i++)
        if (i%3==0) {
            print_tile(rubik, 6, i);
            printf("\n");
        }
        else if (i%3==1) {
            printf("    ");
            print_tile(rubik, 6, i);
        }
        else
            print_tile(rubik, 6, i);

}

void print_tile(Rubik rubik, int a, int b) {
    switch (rubik[a][b]) {
      case 'R':
        printf("R");
        break;
      case 'O':
        printf("O");
        break;
      case 'B':
        printf("B");
        break;
      case 'G':
        printf("G");
        break;
      case 'Y':
        printf("Y");
        break;
      case 'W':
        printf("W");
        break;
      default:
        exit(1);
    }
}

I'm no C-programmer, so correct me if I'm wrong, but I believe you can golf some of your for-loops: for(b=1;b<8;b++)for(a=1;a<11;a++)r[b][a]=c[b]; to for(b=1;b<8;)for(a=1;a<11;)r[b][a++]=c[b++]; and for(i=1;i<=9;i++) to for(i=0;++i<=9;), and some of the other for-loops as well. Also, the else if can be changed to just if when you check if(d==66)B(r);if(d==76)L(r);... And, unless i can be negative, you can change if(i%3==0) to if(i%3<1) two times. And I'm sure it can be golfed some more. Nice to see an answer on your own challenge, though. :)

I tried golfing the loops down, but it didn't work, so I decided not to touch them. I'm outside and can't try them now. But you're right about ifs and i though, I'll edited them once I go home. Thanks!

@KevinCruijssen removing elses bork the program, golfing loops bork the program, the thing with i works. Thanks anyway.

Hmm, why does the else if changing to if fail? :S In each of the else ifs you compare d==##, so I'm confused why it doesn't. Again, I don't program C, so maybe I'm missing something obvious that C can't do, but still.. Ah well, glad I could help with the modulo <1 instead of ==0

Oh I got it now while looking to the ungolfed code. The elses that follow ifs don't require braces but since I removed the elses I have to put the braces back.

979 bytes

Javascript (ES5), 1615 bytes
function m(a){b=[];b[0]=a[6];b[2]=a[0];b[8]=a[2];b[6]=a[8];b[1]=a[3];b[5]=a[1];b[7]=a[5];b[3]=a[7];b[4]=a[4];return b}function q(a,b){c=[];c[0]=b[0];c[1]=b[1];c[2]=a[2];c[3]=b[3];c[4]=b[4];c[5]=a[5];c[6]=b[6];c[7]=b[7];c[8]=a[8];return c}function r(a){var b=[];b[0]=m(a[0]);b[1]=q(a[2],a[1]);b[4]=q(a[1],a[4]);b[3]=q(a[4],a[3]);b[2]=q(a[3],a[2]);b[5]=a[5];return b}function x(a){var b=[];b[0]=m(a[0]);b[1]=a[2];b[2]=a[3];b[3]=a[4];b[4]=a[1];b[5]=m(m(m(a[5])));return b}function y(a){var b=[];b[0]=a[4];b[1]=m(a[1]);b[2]=a[0];b[3]=m(m(m(a[3])));b[4]=a[5];b[5]=a[2];return b}function s(a){a=a.replace(/F2/,"F F");a=a.replace(/R2/,"R R");a=a.replace(/U2/,"U U");a=a.replace(/D2/,"D D");a=a.replace(/B2/,"B B");a=a.replace(/L2/,"L L");a=a.replace(/F'/,"F F F");a=a.replace(/R'/,"R R R");a=a.replace(/U'/,"U U U");a=a.replace(/D'/,"D D D");a=a.replace(/B'/,"B B B");a=a.replace(/L'/,"L L L");a=a.replace(/F/,"y y y R y");a=a.replace(/L/,"y y R y y");a=a.replace(/U/,"x y R y y y x x x");a=a.replace(/B/,"y R y y y");a=a.replace(/D/,"x y y y R y x x x");a=a.split(" ");for(b=["RRRRRRRRR".split(""),"WWWWWWWWW".split(""),"GGGGGGGGG".split(""),"YYYYYYYYY".split(""),"BBBBBBBBB".split(""),"OOOOOOOOO".split("")],c=0;c<a.length;++c)"x"==a[c]?b=x(b):"y"==a[c]?b=y(b):"R"==a[c]&&(b=r(b));return p(b)}function p(a){for(var b="",c=0;3>c;++c)b+="\n   "+a[1][3*c+0]+a[1][3*c+1]+a[1][3*c+2];for(c=0;3>c;++c)b+="\n"+a[5][3*c+0]+a[5][3*c+1]+a[5][3*c+2]+a[2][3*c+0]+a[2][3*c+1]+a[2][3*c+2]+a[0][3*c+0]+a[0][3*c+1]+a[0][3*c+2]+a[4][3*c+0]+a[4][3*c+1]+a[4][3*c+2];for(c=0;3>c;++c)b+="\n   "+a[3][3*c+0]+a[3][3*c+1]+a[3][3*c+2];return b}

Ungolfed:
function m(fac){ //Turn a face
    //0 1 2
    //3 4 5
    //6 7 8

    var fac2=[];
    fac2[0]=fac[6];
    fac2[2]=fac[0];
    fac2[8]=fac[2];
    fac2[6]=fac[8];

    fac2[1]=fac[3];
    fac2[5]=fac[1];
    fac2[7]=fac[5];
    fac2[3]=fac[7];

    fac2[4]=fac[4];

    return fac2;
}

function q(face1,face3){ //Swap right third of two faces
    var face2=[];
    face2[0]=face3[0];
    face2[1]=face3[1];
    face2[2]=face1[2];
    face2[3]=face3[3];
    face2[4]=face3[4];
    face2[5]=face1[5];
    face2[6]=face3[6];
    face2[7]=face3[7];
    face2[8]=face1[8];
    return face2;
}

function r(state){ //Apply a R move
    var state2=[];
    state2[0]=m(state[0]);
    //Swap right set of Front, Up, Back, Down (2,1,4,3);

    state2[1]=q(state[2],state[1]);
    state2[4]=q(state[1],state[4]);
    state2[3]=q(state[4],state[3]);
    state2[2]=q(state[3],state[2]);
    state2[5]=state[5];
    return state2;
}

function x(staten){ //Apply a x move
    var state2=[];
    state2[0]=m(staten[0]);
    state2[1]=staten[2];
    state2[2]=staten[3];
    state2[3]=staten[4];
    state2[4]=staten[1];
    state2[5]=m(m(m(staten[5])));
    return state2;
}

function y(state){ //Apply a y move
    var state2=[];
    state2[0]=state[4];
    state2[1]=m(state[1]);
    state2[2]=state[0];
    state2[3]=m(m(m(state[3])));
    state2[4]=state[5];
    state2[5]=state[2];
    return state2;
}

function s(algo){ //Solve a cube, representing every move with x, y and R
    algo=algo.replace(/F2/,"F F");
    algo=algo.replace(/R2/,"R R");
    algo=algo.replace(/U2/,"U U");
    algo=algo.replace(/D2/,"D D");
    algo=algo.replace(/B2/,"B B");
    algo=algo.replace(/L2/,"L L");

    algo=algo.replace(/F'/,"F F F");
    algo=algo.replace(/R'/,"R R R");
    algo=algo.replace(/U'/,"U U U");
    algo=algo.replace(/D'/,"D D D");
    algo=algo.replace(/B'/,"B B B");
    algo=algo.replace(/L'/,"L L L");

    algo=algo.replace(/F/,"y y y R y");
    algo=algo.replace(/L/,"y y R y y");
    algo=algo.replace(/U/,"x y R y y y x x x");
    algo=algo.replace(/B/,"y R y y y");
    algo=algo.replace(/D/,"x y y y R y x x x");

    algo=algo.split(" ");

    var cstate=[["R","R","R","R","R","R","R","R","R"],["W","W","W","W","W","W","W","W","W"],["G","G","G","G","G","G","G","G","G"],["Y","Y","Y","Y","Y","Y","Y","Y","Y"],["B","B","B","B","B","B","B","B","B"],["O","O","O","O","O","O","O","O","O"]];

    for(var i=0;i<algo.length;++i){
        if(algo[i]=="x"){
            cstate=x(cstate);
        }else if(algo[i]=="y"){
            cstate=y(cstate);
        }else if(algo[i]=="R"){
            cstate=r(cstate);
        }
    }

    return p(cstate);
}

function p(cstate){ //Print
    var out="";
    var leftspace="\n   ";
    for(var i=0;i<3;++i){
        out+=leftspace+cstate[1][3*i+0]+cstate[1][3*i+1]+cstate[1][3*i+2]
    }
    for(var i=0;i<3;++i){
        out+="\n"+cstate[5][3*i+0]+cstate[5][3*i+1]+cstate[5][3*i+2]+cstate[2][3*i+0]+cstate[2][3*i+1]+cstate[2][3*i+2]+cstate[0][3*i+0]+cstate[0][3*i+1]+cstate[0][3*i+2]+cstate[4][3*i+0]+cstate[4][3*i+1]+cstate[4][3*i+2]
    }
    for(var i=0;i<3;++i){
        out+=leftspace+cstate[3][3*i+0]+cstate[3][3*i+1]+cstate[3][3*i+2]
    }
    return out;
}

This was a very difficult challenge.
Explanation
Take the example call s("R U' F").
The program can only execute x, y and R moves.
U' is equal to U U U, so replace that.
F is equal to y y y R y, so replace that.
R U' F' is therefore equal to R U U U y y y R y, which the program can run.
cstate is defined with a solved cube. A cube is represented by an array containing 6 arrays containing the 9 stickers. The first array is for R, second for U, third for F, D, B, last array is for L.
When an y needs to be executed, the program swaps the four arrays of the front, left, back and right face. For an x, it swaps front, down, back and top. Every rotation also rotates the other faces, that were not swapped. A R move rotates the right face and swaps the right part of the front, up, back, down face.
This could be modified to be able to solve problems with all types of moves, by defining them with x, y and R.

I'm working on stealing your concept of only 3 moves to make my own shorter ;) Great Idea

So R U' F2 gets converted to R U' F F first, then R U U U F F, then R x y R y y y x x x x y R y y y x x x x y R y y y x x x y y y R y y y y R y which it then executes? Weird.. but very original. +1 :) How did you came up with this idea?

My code converts U' into U U U too, but xes and ys are really good. I want to steal this too :p

@KevinCruijssen Rotations are much easier to program than move affecting one layer only. I first tried this concept with a program for simulating NxN cubes, and now implemented an easier version here. It first removes any ' and 2, and then replaces all moves.

Well done but still golfable. I'm trying to port it to ES6

The problem is it does not work even for the simplest move. (tried in FireFox)

problem 1 - all the replaces should be /g

problem 2 - the variable b should be local in all functions

@edc65 A lot of stuff can be improved, but I currently don't have the time. Feel free to correct/improve my code and post it as your version.

Python 3, 528 bytes
-7 bytes thanks to my colleague rhsmits (really nice d,*c form & removal of redundant parentheses)
This is a full program.
import re
d,*c=[[f]*9for f in' YBRGOW']
r=lambda f:[f[int(v)]for v in'630741852']
U=lambda c:[r(c[0])]+[c[j%4+1][:3]+c[j][3:]for j in(1,2,3,4)]+[c[5]]
y=lambda c:[r(c[0])]+c[2:5]+[c[1],r(r(r(c[5])))]
z=lambda c:[c[2],r(r(r(c[1]))),c[5],r(c[3]),c[0][::-1],c[4][::-1]]
exec("c="+"(c);c=".join("".join("zzzUz U zzUzz yyyzUzzzy zUzzz yzUzzzyyy".split()[ord(t)%11%7]*(ord(n or'a')%6)for t,n in re.findall("([B-U])(['2i]?)",input())))+"(c)")
k=' '.join
for q in[d,c[0]],c[1:5],[d,c[5]]:
 for w in 0,3,6:print(k(k(f[w:w+3])for f in q))

Superflip and all tests are available at ideone or Try it online!
The program:

creates the six faces YBRGOW of stickers.
creates a function, r, which only rotates the stickers on a face, clockwise a quarter-turn
creates a function, U, which rotates the U face clockwise a quarter-turn by applying r and rotating the stickers on the top-band of LFRB clockwise a quarter-turn
creates a function, y, which performs r on the U and D faces and slices LFRB
- this performs a rotation of the whole cube in the y axis (which runs through U and D)
- the rotation is clockwise if looking from above
creates a function z, which performs a rotation of the whole cube in the z axis clockwise a quarter turn looking at R (the axis runs through R and L) - this time because the way the faces are oriented in our net (same as given in the OP) we have to flip the B and U faces over (they switch from the horizontal to vertical parts of the net and vice-versa)
Performs a regex on the input, input(), (the moves to be performed) matching a character from BUDLRF (actually B-U) possibly followed by a character 'i2
Performs a mapping from the 'i2 to the number of clockwise turns (the ordinals of these mod 6 does the job, with a dummy a to yield 1 when none is present)
Performs a lookup to map each of these single clockwise turn instructions to a setup of calls to y and z, a quarter-turn of U (which will now be the face instructed), and then the calls to inverse the sequence of the setup performed. Taking the ordinal of the face character modulo by 11 then by 7 maps B:0 U:1 D:2 L:3 F:4 R:5, allowing a simple indexing into a string of the function name sequences split by spaces.
executes the string to actually perform the manoeuvre
creates a dummy face d to shorten the printing
prints the result by stepping through the rows in the net and the faces in the row (including a dummy face to the left of each of U and D

Here is the superflip:
D:\Python Scripts>python rubiksAscii.py
U R2 F B R B2 R U2 L B2 R U' D' R2 F R' L B2 U2 F2
      Y O Y
      B Y G
      Y R Y
B Y B R Y R G Y G O Y O
O B R B R G R G O G O B
B W B R W R G W G O W O
      W R W
      B W G
      W O W

Python 760 750 649 Bytes
shamelessly stole the idea of using only 3 rotations from @Paul Schmitz :D
new version:
from numpy import*
c=kron([[32,89,32,32],[66,82,71,79],[32,87,32,32]],ones([3,3])).astype(int)
def x():t=copy(c);c[:3,3:6],c[3:6,3:6],c[6:,3:6],c[3:6,9:],c[3:6,:3],c[3:6,6:9]=t[3:6,3:6],t[6:,3:6],rot90(t[3:6,9:],2),rot90(t[:3,3:6],2),rot90(t[3:6,:3]),rot90(t[3:6,6:9],3)
def y():c[3:6],c[:3,3:6],c[6:,3:6]=roll(c[3:6],3,1),rot90(c[:3,3:6]),rot90(c[6:,3:6],3)
def F():c[2:7,2:7]=rot90(c[2:7,2:7],3)
s=raw_input()
for p in"':i,Fi:FFF,F2:FF,Bi:BBB,B2:BB,Ri:RRR,R2:RR,Li:LLL,L2:LL,Ui:UUU,U2:UU,Di:DDD,D2:DD,B:xxFxx,R:yyyFy,L:yFyyy,U:xxxFx,D:xFxxx".split(','):s=s.replace(*p.split(':'))
for S in s:eval(S+'()')
for r in c:print(''.join(chr(x)for x in r))

I mostly just did lots of numpy list slicing and used its built in rotate and roll functions. Input is handled by calling the functions directly with eval()
from numpy import*
l=[0];c=kron([[32,89,32,32],[66,82,71,79],[32,87,32,32]],ones([3,3])).astype(int)
def i():l[0]();l[0]()
def d():l[0]()
def U():c[:3,3:6]=rot90(c[:3,3:6],3);c[3]=roll(c[3],9);l[0]=U
def D():c[6:,3:6]=rot90(c[6:,3:6],3);c[5]=roll(c[5],3);l[0]=D
def F():c[2:7,2:7]=rot90(c[2:7,2:7],3);l[0]=F
def B():c[3:6,9:]=rot90(c[3:6,9:],3);t=copy(c);c[:,:9],c[1:-1,1:8]=rot90(t[:,:9]),t[1:-1,1:8];l[0]=B
def R():c[3:6,6:9]=rot90(c[3:6,6:9],3);t=copy(c);c[:6,5],c[3:6,9],c[6:,5]=t[3:,5],t[2::-1,5],t[5:2:-1,9];l[0]=R
def L():c[3:6,:3]=rot90(c[3:6,:3],3);t=copy(c);c[3:,3],c[3:6,-1],c[:3,3]=t[:6,3],t[:5:-1,3],t[5:2:-1,-1];l[0]=L
for s in raw_input().replace("'",'i').replace('2','d').replace(' ',''):eval(s+'()')
for r in c:print(''.join(chr(x)for x in r))

ungolfed..
import numpy as np
last = [0] #store last move to repeat for inverse or double
           #list is shorter syntax than global var

cube = np.array([
[' ',' ',' ','Y','Y','Y',' ',' ',' ',' ',' ',' '],
[' ',' ',' ','Y','Y','Y',' ',' ',' ',' ',' ',' '],
[' ',' ',' ','Y','Y','Y',' ',' ',' ',' ',' ',' '],
['B','B','B','R','R','R','G','G','G','O','O','O'],
['B','B','B','R','R','R','G','G','G','O','O','O'],
['B','B','B','R','R','R','G','G','G','O','O','O'],
[' ',' ',' ','W','W','W',' ',' ',' ',' ',' ',' '],
[' ',' ',' ','W','W','W',' ',' ',' ',' ',' ',' '],
[' ',' ',' ','W','W','W',' ',' ',' ',' ',' ',' ']
]) #ascii ascii codes in golfed version

def i(): #triple move (inverse)
    last[0]()
    last[0]()

def d(): #double move
    last[0]()

def U(): #clockwise upface (yellow)
    cube[:3,3:6] = np.rot90(cube[:3,3:6],3)
    cube[3] = np.roll(cube[3],9)
    last[0] = U

def D(): #clockwise downface (white)
    cube[6:,3:6] = np.rot90(cube[6:,3:6],3)
    cube[5] = np.roll(cube[5],3)
    last[0] = D

def F(): #clockwise frontface (red)
    cube[2:7,2:7] = np.rot90(cube[2:7,2:7],3)
    last[0] = F

def B(): #clockwise backface (orange)
    cube[3:6,9:] = np.rot90(cube[3:6,9:],3)
    tempCube = np.copy(cube)
    cube[:,:9],cube[1:-1,1:8] = np.rot90(tempCube[:,:9]),tempCube[1:-1,1:8]
    last[0] = B

def R(): #clockwise rightface (green)
    cube[3:6,6:9] = np.rot90(cube[3:6,6:9],3)
    tempCube = np.copy(cube)
    cube[:6,5],cube[3:6,9],cube[6:,5] = tempCube[3:,5],tempCube[2::-1,5],tempCube[5:2:-1,9]
    last[0] = R

def L(): #clockwise leftface (blue)
    cube[3:6,:3] = np.rot90(cube[3:6,:3],3)
    tempCube = np.copy(cube)
    cube[3:,3],cube[3:6,-1],cube[:3,3] = tempCube[:6,3],tempCube[:5:-1,3],tempCube[5:2:-1,-1]
    last[0] = L

for character in raw_input('type a move sequence: ').replace("'",'i').replace('2','d').replace(' ',''):
    eval(character+'()')

print("-"*12)

for row in cube:
    print(''.join(character for character in row)) #uses ascii codes in golfed version

test input:
>>> runfile('C:~/rubiks cube.py', wdir='C:~/python/golf')
U2 L' D
   OYY
   RYY
   RYY
GBBWOOBBBRRY
GBBWRRGGGOOY
OOYGBBWRRGGG
   ROO
   WWW
   WWW

Comments or suggestions are greatly appreciated :)

of using only 3 rotations wrong. The program converts any sequence into a sequence with more moves. If you input F F F F, it uses more than 3 rotations, as it converts to y y y R y y y y R y y y y R y y y y R y. It uses three types of rotations.

@PaulSchmitz three types is what I meant.... conversions are listed in the string in the seventh line

C, 839 bytes
#include <stdio.h>
#define b(c) c,c+1,c+2,c+15,c+28,c+27,c+26,c+13
char a[]="   YYY      \n   YYY      \n   YYY      \nBBBRRRGGGOOO\nBBBRRRGGGOOO\nBBBRRRGGGOOO\n   WWW      \n   WWW      \n   WWW      \n",k;int d[][8]={b(3),b(39),b(42),b(45),b(48),b(81)},e[][12]={50,49,48,47,46,45,44,43,42,41,40,39,3,16,29,42,55,68,81,94,107,76,63,50,29,30,31,45,58,71,83,82,81,67,54,41,109,96,83,70,57,44,31,18,5,48,61,74,39,52,65,107,108,109,73,60,47,5,4,3,65,66,67,68,69,70,71,72,73,74,75,76},i,*j,r,p,q,s;f(int*g,int h){i=h<0?-1:1;for(j=g;j!=g+h;j+=i){k=a[j[3*h]];for(r=3;r--;)a[j[r*h+h]]=a[j[r*h]];a[*j]=k;}}l(int g,int m){f(d[g+m]-m,m?-2:2);f(e[g+m]-m,m?-3:3);}void n(char*o){while(*o){*o-'U'||(p=0);*o-'L'||(p=1);*o-'F'||(p=2);*o-'R'||(p=3);*o-'B'||(p=4);*o-'D'||(p=5);s=*++o=='\''||*o=='i';q=*o=='2';(s||q)&&o++;l(p,s);q&&l(p,0);}printf("%s",a);}

As this is not a full program (function with input from a string argument and output to the console), you need to call it like this:
int main() {
//  n("U2D2R2L2F2B2");    //checker cube
    n("UDiRL'FBiUD'");    //spotted cube
}

Use only one call at a time as the function uses and modifies global variables.
Ungolfed:
#include <stdio.h>

char cube[] = "   YYY      \n"
              "   YYY      \n"
              "   YYY      \n"
              "BBBRRRGGGOOO\n"
              "BBBRRRGGGOOO\n"
              "BBBRRRGGGOOO\n"
              "   WWW      \n"
              "   WWW      \n"
              "   WWW      \n";

#define faceMove(offset) offset,offset+1,offset+2,offset+15,offset+28,offset+27,offset+26,offset+13
int faceMoves[6][8] = {
    faceMove(3),    //Up
    faceMove(39),   //Left
    faceMove(42),   //Front
    faceMove(45),   //Right
    faceMove(48),   //Back
    faceMove(81)    //Down
}, lineMoves[6][12] = {
    50,49,48,47,46,45,44,43,42,41,40,39,    //Up
    3,16,29,42,55,68,81,94,107,76,63,50,    //Left
    29,30,31,45,58,71,83,82,81,67,54,41,    //Front
    109,96,83,70,57,44,31,18,5,48,61,74,    //Right
    39,52,65,107,108,109,73,60,47,5,4,3,    //Back
    65,66,67,68,69,70,71,72,73,74,75,76 //Down
};

int rotate(int*move,int rotation){
    int sign=rotation<0?-1:1;
    for(int*submove=move;submove!=move+rotation;submove+=sign){
        char takeout=cube[submove[3*rotation]];
        for(int j=3;j--;)cube[submove[j*rotation+rotation]]=cube[submove[j*rotation]];
        cube[*submove]=takeout;
    }
}

int move(int move,int inverted){
    rotate(faceMoves[move+inverted]-inverted,inverted?-2:2);
    rotate(lineMoves[move+inverted]-inverted,inverted?-3:3);
}

void performMoves(char*instructions){
    while(*instructions){
        int moveIndex;
        *instructions-'U'||(moveIndex=0);
        *instructions-'L'||(moveIndex=1);
        *instructions-'F'||(moveIndex=2);
        *instructions-'R'||(moveIndex=3);
        *instructions-'B'||(moveIndex=4);
        *instructions-'D'||(moveIndex=5);
        int inverted=*++instructions=='\''||*instructions=='i', twice=*instructions=='2';
        (inverted||twice)&&instructions++;
        move(moveIndex,inverted);
        twice&&move(moveIndex,0);
    }
    printf("%s",cube);
}

int main() {
//  performMoves("U2D2R2L2F2B2");    //checker cube
    performMoves("UDiRL'FBiUD'");    //spotted cube
}

As you can see, the main idea is to use a fully data-driven approach: The different rotations are expressed as lists of indices that have to be permuted. The permutation code can thus be very short and generic.

Welcome to PPCG! Nice first post!

You can do the following to save more bytes: f(h,g)int*g;{ -2, l(g,m){ -8, n(char*o){ -5, printf("%s",a) to puts(a) -7, also you can replace char constants with their ASCII decimal representation -1 each

572 bytes

Cubically, 2 bytes
¶■

Try it online!
Explanation:
¶   read a line from stdin, evaluate
 ■  print the cube to stdout

If extraneous output is allowed, this is an alternative. 1 byte:
¶

Try it online!
Cubically automatically dumps its memory cube to STDERR when the program ends. However, it also prints the notepad beforehand.

I don't know whether to applaud or boo you. +1

@JoKing Both. Just like when Cubically pwns other cube challenges. 1 2 3

JavaScript (ES6), 820
A porting of the buggy answer by @Paul Schmitz. It's still not completely golfed, but it has the added value that it works.
The main problem in the original answer is that a single function Q is not enough for all the movements involved in a rotation. I had to add 2 other functions O and N. All of them are just called in the right rotation function R.
(a,M=a=>[a[6],a[3],a[0],a[7],a[4],a[1],a[8],a[5],a[2]],Q=(a,b)=>[b[0],b[1],a[2],b[3],b[4],a[5],b[6],b[7],a[8]],N=(a,b)=>[b[0],b[1],a[6],b[3],b[4],a[3],b[6],b[7],a[0]],O=(a,b)=>[b[8],a[1],a[2],b[5],a[4],a[5],b[2],a[7],a[8]],R=a=>[M(a[0]),Q(a[2],a[1]),Q(a[3],a[2]),N(a[4],a[3]),O(a[4],a[1]),a[5]],X=a=>[M(a[0]),a[2],a[3],M(M(a[4])),M(M(a[1])),M(M(M(a[5])))],Y=a=>[a[4],M(a[1]),a[0],M(M(M(a[3]))),a[5],a[2]],F=c=>Array(9).fill(c[0]),r='replace',b=[F`G`,F`Y`,F`R`,F`W`,F`O`,F`B`],J=(p,l)=>p.join``[r](/.../g,l))=>(a[r](/(.)2/g,"$1$1")[r](/(.)['i]/g,"$1$1$1")[r](/F/g,"yyyRy")[r](/L/g,"yyRyy")[r](/B/g,"yRyyy")[r](/U/g,"xyRyyyxxx")[r](/D/g,"xyyyRyxxx")[r](/\w/g,c=>b=(c<'a'?R:c<'y'?X:Y)(b)),o=J(b[1],`
   $&`),J(b[5],(c,p)=>o+=`
`+c+b[2].join``.substr(p,3)+b[0].join``.substr(p,3)+b[4].join``.substr(p,3)),o+J(b[3],`
   $&`))

More readable maybe
(
  a,
  // local variables as default parameters
  r='replace',
  F=c=>Array(9).fill(c[0]), // function to fill a 3x3 square
  b=[F`G`,F`Y`,F`R`,F`W`,F`O`,F`B`], // cube status
  // aux functions to perform basic moves
  M=a=>[a[6],a[3],a[0],a[7],a[4],a[1],a[8],a[5],a[2]],
  Q=(a,b)=>[b[0],b[1],a[2],b[3],b[4],a[5],b[6],b[7],a[8]],
  N=(a,b)=>[b[0],b[1],a[6],b[3],b[4],a[3],b[6],b[7],a[0]],
  O=(a,b)=>[b[8],a[1],a[2],b[5],a[4],a[5],b[2],a[7],a[8]],
  // R : right side rotation
  R=a=>[M(a[0]),Q(a[2],a[1]),Q(a[3],a[2]),N(a[4],a[3]),O(a[4],a[1]),a[5]],
  // X,Y: to put other sides in place of right side
  X=a=>[M(a[0]),a[2],a[3],M(M(a[4])),M(M(a[1])),M(M(M(a[5])))],
  Y=a=>[a[4],M(a[1]),a[0],M(M(M(a[3]))),a[5],a[2]],
  // aux function for output
  J=(p,l)=>p.join``[r](/.../g,l),
) => (
  // convert common moves to basic moves
  a[r](/(.)2/g,"$1$1")[r](/(.)['i]/g,"$1$1$1")[r](/F/g,"yyyRy")[r](/L/g,"yyRyy")[r](/B/g,"yRyyy")[r](/U/g,"xyRyyyxxx")[r](/D/g,"xyyyRyxxx")
  // then execute each
  [r](/\w/g,c=>b=c<'a'?R(b):c<'y'?X(b):Y(b)),
  // built output in o
  o=J(b[1],'\n   $&'),
  J(b[5],(c,p)=>o+='\n'+c+b[2].join``.substr(p,3)+b[0].join``.substr(p,3)+b[4].join``.substr(p,3)),
  o+J(b[3],'\n   $&') // returned output
)

S=
(a,M=a=>[a[6],a[3],a[0],a[7],a[4],a[1],a[8],a[5],a[2]],Q=(a,b)=>[b[0],b[1],a[2],b[3],b[4],a[5],b[6],b[7],a[8]],N=(a,b)=>[b[0],b[1],a[6],b[3],b[4],a[3],b[6],b[7],a[0]],O=(a,b)=>[b[8],a[1],a[2],b[5],a[4],a[5],b[2],a[7],a[8]],R=a=>[M(a[0]),Q(a[2],a[1]),Q(a[3],a[2]),N(a[4],a[3]),O(a[4],a[1]),a[5]],X=a=>[M(a[0]),a[2],a[3],M(M(a[4])),M(M(a[1])),M(M(M(a[5])))],Y=a=>[a[4],M(a[1]),a[0],M(M(M(a[3]))),a[5],a[2]],F=c=>Array(9).fill(c[0]),r='replace',b=[F`G`,F`Y`,F`R`,F`W`,F`O`,F`B`],J=(p,l)=>p.join``[r](/.../g,l))=>(a[r](/(.)2/g,"$1$1")[r](/(.)['i]/g,"$1$1$1")[r](/F/g,"yyyRy")[r](/L/g,"yyRyy")[r](/B/g,"yRyyy")[r](/U/g,"xyRyyyxxx")[r](/D/g,"xyyyRyxxx")[r](/\w/g,c=>b=(c<'a'?R:c<'y'?X:Y)(b)),o=J(b[1],`
   $&`),J(b[5],(c,p)=>o+=`
`+c+b[2].join``.substr(p,3)+b[0].join``.substr(p,3)+b[4].join``.substr(p,3)),o+J(b[3],`
   $&`))

function update() { O.textContent=S(I.value) }

update()
<input id=I value='U2 Li D' oninput='update()'><pre id=O></pre>

I get update() is not defined in my console while running the snippet

@KritixiLithos you have probably a sintax error, for not having a ES6 compliant browser. I tested it with Firefox, what browser are you using?

I'm using Chrome

@KritixiLithos my fault, there was an unnecessary comma. Fixed


text:
A cube of text ݀
Last time you made a square of text, but now, can you make a cube of text?
The Challenge
Given a string, output the string in the form of a cube.
You can assume the string will always have 2 chars or more, and will only have printable ascii characters.
How to Make a Text Cube

Test Cases
Input:
Test

Output:
   Test
  e  ss
 s  e e
tseT  T
s  e e
e  ss
Test

Input:
Hello, world!

Output:
            Hello, world!
           e           dd
          l           l l
         l           r  r
        o           o   o
       ,           w    w

     w           ,      ,
    o           o       o
   r           l        l
  l           l         l
 d           e          e
!dlrow ,olleH           H
d           e          e
l           l         l
r           l        l
o           o       o
w           ,      ,

,           w    w
o           o   o
l           r  r
l           l l
e           dd
Hello, world!

Input:
Hi

Output:
 Hi
iHH
Hi

Reference Implementation in Python
text = raw_input("Enter a string: ")

print " " * (len(text) - 1) + text

spaces = len(text) - 2
_spaces = spaces

for i in range(1, len(text) - 2 + 1):
    print " " * spaces + text[i] + " " * _spaces + text[(i + 1) * -1] + " " * (_spaces - spaces) + text[(i + 1) * -1]
    spaces -= 1

print text[::-1] + " " * _spaces + text[0]

spaces = _spaces - 1

for i in range(1, len(text) - 2 + 1):
    print text[(i + 1) * -1] + " " * _spaces + text[i] + " " * spaces + text[i]
    spaces -= 1

print text

Rules

This is code-golf, so shortest answer in bytes wins! Tiebreaker is most upvoted.
Standard loopholes are disallowed.
Trailing newline and trailing spaces are allowed.

Leaderboard
Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

/* Configuration */

var QUESTION_ID = 92410; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 48934; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });

  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (/ b.lang) return 1;
    if (a.lang < b.lang) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}
body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}

<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

Are trailing spaces allowed?

@Neil Yes. (15 chars)

Just curious, what's with the additional characters in the challenge title?

@TimmyD "A cube of text" is 14 characters long, the title needs to be at least 15 characters long, so I added a small dot. I think it's this one.

Ah, OK. It shows up as a much larger circle in IE on my computer, hence my question.

May I draw it with the backlines visible as well? As if you did the wireframe approach?

@carusocomputing no.

Pyth, 78 bytes
AtBtlQJ_SH
+*dGQVJs[*Nd@Q-GN*dHK@QN*d-HNK;
++_Q*dHhQVJs[@QN*dH@Q-GN*dtN@Q-GN;

With trailing newline.   Inspired by Joshua de Haan's Python 3 answer.
Try it online here!

Python 2, 228 223 221 203 199 195 189
t=input()
x=" "
l=len(t)-1
q=l-1
f=range(q,0,-1)
print x*l+t
for i in f:print x*i+t[l-i]+x*q+t[i]+x*(q-i)+t[i]
print t[::-1]+x*q+t[0]
for i in f:print t[i]+x*q+t[l-i]+x*(i-1)+t[l-i]
print t

Python 3, 192 188 182
t=input()
x=" "
l=len(t)-1
q=l-1
p=print
f=range(q,0,-1)
p(x*l+t)
for i in f:p(x*i+t[l-i]+x*q+t[i]+x*(q-i)+t[i])
p(t[::-1]+x*q+t[0])
for i in f:p(t[i]+x*q+t[l-i]+x*(i-1)+t[l-i])
p(t)

That's 203 bytes. Also, you can save 4 bytes by replacing raw_input() with input().

Right you are, thanks!

x*(q)? You should be able to remove the parens, yes?

You're right, silly me ;) Fixing it now haha

x*(i-1) -> x*~-i

x86 (IA-32) machine code, 126 bytes
Hexdump:
60 8b f9 57 33 c0 f2 ae 5e 2b fe 4f 87 fa 8d 1c
12 8b c3 48 f6 e3 c6 04 07 00 48 c6 04 07 20 75
f9 8b ea 4d 53 8d 04 2a 50 53 8b c5 f6 e3 8d 44
68 01 50 53 2b c2 8b c8 50 4b 53 55 53 03 c5 50
f7 d3 53 50 53 95 f6 e2 6b c0 04 50 43 53 51 6a
01 4a 52 6a 01 50 6a ff 51 b0 0a 6a 0b 8b dc 59
8b 6c cb fc 88 04 2f 03 2c cb 89 6c cb fc 83 f9
0a 75 01 ac e2 ea 4a 79 e0 83 c4 58 61 c3

This is a bit long, so to explain it I'll give C code first:
void doit(const char* s, char out[])
{
    int n = strlen(s);
    int w = 2 * n;
    int h = w - 1;
    int m = n - 1;

    memset(out, ' ', h * w);
    out[h * w] = 0;

    int offset1 = n + m;
    int offset2 = w * m + 2 * m + 1; // 2 * n * n - 1
    int offset3 = offset2 - n; // 2 * n * n - n - 1
    int offset4 = 4 * n * m; // 4 * n * n - 4 * n

    int offsets[] = {
        offset3, -1,
        offset4, 1,
        m, 1,
        offset3, 1 - w,
        offset4, -w,
        offset2 - 1, -w,
        offset2 - 1, w - 1,
        m, w - 1,
        offset3, w,
        offset2, w,
        offset1, w,
    };

    do
    {
        char c = *s++;
        for (int i = 0; i < 11; ++i)
        {
            if (i == 9)
                c = '\n';
            int offset = offsets[i * 2];
            assert(offset > 0 && offset < w * h);
            out[offset] = c;
            offsets[i * 2] += offsets[i * 2 + 1];
        }
    } while (--n);
}

Here n is the length of the input string.
The dimensions of the output area are 2n (width) by 2n-1 (height). First, it fills everything with spaces (and adds a terminating null byte). Then, it travels along 11 straight lines in the output area, and fills them with text:

2 lines are filled with end-of-line bytes (=10)
9 lines are filled with the consecutive bytes of the input string

Each line is represented by two numbers, a start offset and a stride. I stuffed them both into the array offsets, to make access "easy".
The interesting part is filling the array. There is little importance for the order of the entries in the array; I tried to rearrange them to minimize the number of register conflicts. In addition, quadratic formulas have some freedom in choosing the way of calculation; I tried to minimize the number of subtractions (because additions can be implemented by the flexible LEA instruction).
Assembly source:
    pushad;

    ; // Calculate the length of the input string
    mov edi, ecx;
    push edi;
    xor eax, eax;
    repne scasb;
    pop esi; // esi = input string
    sub edi, esi;
    dec edi;

    ; // Calculate the size of the output area
    xchg edi, edx;  // edx = n
                    // edi = output string
    lea ebx, [edx + edx]; // ebx = w
    mov eax, ebx;
    dec eax; // eax = h
    mul bl; // eax = w * h

    ; // Fill the output string with spaces and zero terminate it
    mov byte ptr [edi + eax], 0;
myfill:
    dec eax;
    mov byte ptr [edi + eax], ' ';
    jnz myfill;

    mov ebp, edx;
    dec ebp; // ebp = m

    ; // Fill the array of offsets
    push ebx; // w
    lea eax, [edx + ebp];
    push eax; // offset1
    push ebx; // w
    mov eax, ebp;
    mul bl;
    lea eax, [eax + 2 * ebp + 1];
    push eax; // offset2
    push ebx; // w
    sub eax, edx;
    mov ecx, eax; // ecx = offset3
    push eax; // offset3
    dec ebx;
    push ebx; // w - 1
    push ebp; // m
    push ebx; // w - 1
    add eax, ebp;
    push eax; // offset2 - 1
    not ebx;
    push ebx; // -w
    push eax; // offset2 - 1
    push ebx; // -w
    xchg eax, ebp; // eax = m
    mul dl;
    imul eax, eax, 4;
    push eax; // offset4
    inc ebx;
    push ebx; // 1 - w
    push ecx; // offset3
    push 1;
    dec edx; // edx = n - 1
    push edx;
    push 1;
    push eax;
    push -1;
    push ecx;

    ; // Use the array of offsets to write stuff to output
myout:
    mov al, '\n';
    push 11;
    mov ebx, esp;
    pop ecx;
myloop:
    mov ebp, [ebx + ecx * 8 - 4];
    mov [edi + ebp], al;
    add ebp, [ebx + ecx * 8];
    mov [ebx + ecx * 8 - 4], ebp;
    cmp ecx, 10;
    jne skip_read;
    lodsb;
skip_read:
    loop myloop;
    dec edx;
    jns myout;

    add esp, 11 * 8;

    popad;
    ret;

I used byte multiplications here, limiting the length of the input string to 127. This avoids clobbering the register edx - the product is calculated in ax instead.
A minor glitch: when filling the array, the length of the string gets decreased by 1. So I adjusted the loop exit condition:
    jns myout

It counts down to -1.

Ruby, 148 144 bytes
+1 byte from the n flag. Shows newlines instead of semicolons for readability (same functionality).
S=" "
X=S*s=$_.size-2
puts X+S+I=$_,(r=1..s).map{|i|c=I[~i];S*(s-i+1)+I[i]+X+c+S*~-i+c},I.reverse+X+I[0],r.map{|i|c=I[i];I[~i]+X+c+S*(s-i)+c},I

Run like so. Input is a line of STDIN, with no trailing newline, so it likely needs to be piped from file.
ruby -ne 'S=" ";X=S*s=$_.size-2;puts X+S+I=$_,(r=1..s).map{|i|c=I[~i];S*(s-i+1)+I[i]+X+c+S*~-i+c},I.reverse+X+I[0],r.map{|i|c=I[i];I[~i]+X+c+S*(s-i)+c},I'

Javascript, 225 198 bytes
Saved 27 bytes thanks to @Neil
f=(s,l=s.length-2,d=' ',r='repeat',t=d[r](l))=>[d+t+s,...a=[...Array(l)].map((_,i)=>d[r](l-i)+s[i+1]+t+(p=s[l-i])+d[r](i)+p),[...s].reverse().join``+t+s[0],...a.map(v=>v.trim()).reverse(),s].join`
`

[...] instead of .concat
[...]+map instead of for loop
only one statement by moving variables as function parameters
better initialization for l and t

Original answer:
f=s=>{l=s.length,d=' ',r='repeat',a=[],t=d[r](l-2)+s;for(i=1;i++<l-1;)a.push(d[r](l-i)+s[i-1]+d[r](l-2)+(p=s[l-i])+d[r](i-2)+p);console.log(d+[t].concat(a,[...t].reverse().join``+s[0],a.map(v=>v.trim()).reverse(),s).join`
`)}

Nice, although golfable: (s,l=s.length-2,d=' ',r='repeat',t=d[r](l))=>[d+t+s,...a=[...Array(l)].map((_,i)=>d[r](l-i)+s[i+1]+t+(p=s[l-i])+d[r](i)+p),[...s].reverse().join\`+t+s[0],...a.map(v=>v.trim()).reverse(),s].join`\n`(using\n` because you can't put newlines in comments).

Java 7, 283 bytes
void a(String s){int h=s.length(),n=h*2-1,t=n-h,u=n-1;char[][]c=new char[n][n];for(int i=0;i<h;i++){c[0][t+i]=c[i][t-i]=c[t][t-i]=c[t+i][t]=c[t+i][u-i]=c[t-i][t+i]=c[t-i][u]=c[u][i]=c[u-i][0]=s.charAt(i);}for(int y=0;y<n;y++){System.out.println(new String(c[y]).replace('\0',' '));}}

Try it here!
Ungolfed:
void a(String s) {
    int length=s.length(),
        n=length*2-1,
        mid=n-length,
        doubleMid=n-1;
    char[][]c=new char[n][n];
    for(int i=0;i<length;i++) {
        c[0][mid+i]=
        c[i][mid-i]=
        c[mid][mid-i]=
        c[mid+i][mid]=
        c[mid+i][doubleMid-i]=
        c[mid-i][mid+i]=
        c[mid-i][doubleMid]=
        c[doubleMid][i]=
        c[doubleMid-i][0]=s.charAt(i);
    }
    for(int y=0;y<n;y++){
        System.out.println(new String(c[y]).replace('\0',' '));
    }
}

source: Stack Exchange

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

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

sort: votes


text:
Greater than less than greater than something fishy
Given a length N string of less-than and greater-than signs (<, >), insert the integers 0 through N at the start and end and in between each pair of signs such that all the inequalities are satisfied. Output the resulting string. If there are multiple valid outputs, output any one (and just one) of them.
For example
<<><><<

has 7 characters so all the numbers from 0 to 7 inclusive must be inserted. A valid output is
2<3<4>1<5>0<6<7

because all the inequalities taken one at a time
2<3
3<4
4>1
1<5
5>0
0<6
6<7

are true.
If desired, the output may have spaces surrounding the signs, e.g. 2 < 3 < 4 > 1 < 5 > 0 < 6 < 7.
The shortest code in bytes wins.
Test Cases
The first line after an empty line is the input and the next line(s) are each valid output examples.
[empty string]
0

<
0<1

>
1>0

<<
0<1<2

<>
1<2>0

><
1>0<2
2>0<1

>>
2>1>0

<<<
0<1<2<3

><>
1>0<3>2

>><
3>2>0<1
3>1>0<2
2>1>0<3

>>>
3>2>1>0

>>><<<
3>2>1>0<4<5<6
6>3>1>0<2<4<5
4>2>1>0<3<5<6
4>3>1>0<2<5<6

<<><><<
2<3<4>1<5>0<6<7

>><><>>
7>6>0<5>1<4>3>2

<<<<<<<<<<<<<<
0<1<2<3<4<5<6<7<8<9<10<11<12<13<14

>><<<<><>><><<
6>5>4<7<8<9<10>3<11>2>1<12>0<13<14
14>5>4<7<8<9<10>3<11>2>1<12>0<13<6

Will there always be a valid output?

@mbomb007 Yes. There always is at least one.

I want to see someone program this in ><>! That would be awesome (and ironic I guess?)

This was a really fun but simply challenge, thanks op

Not sure if you're listing all valid outputs or just some example possible outputs, but if the first, test case <> can also be 0<2>1 as possible valid output.

Retina, 20 bytes
Byte count assumes ISO 8859-1 encoding.

$.'
S`>
%O#`\d+
¶
>
Try it online! (The first line enables a linefeed-separated test-suite.)
Explanation
A simple way to find a valid permutation is to start by inserting the numbers from 0 to N in order, and then to reverse the numbers surrounding each substring of >s. Take <><<>>><< as an example:
0<1>2<3<4>5>6>7<8<9
  ---   -------      these sections are wrong, so we reverse them
0<2>1<3<7>6>5>4<8<9

Both of those tasks are fairly simple in Retina, even though all we can really work with are strings. We can save an additional byte by inserting the numbers from N down to 0 and reversing the sections surrounding < instead, but the principle is the same.
Stage 1: Substitution

$.'
We start by inserting the length of $' (the suffix, i.e. everything after the match) into every possible position in the input. This inserts the numbers from N down to 0.
Stage 2: Split
S`>

We split the input around > into separate lines, so each line is either an individual number or a list of numbers joined with <.
Stage 3: Sort
%O#`\d+

Within each line (%) we sort (O) the numbers (\d#) by their numerical value (#). Since we inserted the number in reverse numerical order, this reverses them.
Stage 4: Substitution
¶
>

We turn the linefeeds into > again to join everything back into a single line. That's it.
As a side note, I've been meaning to add a way to apply % to other delimiters than linefeeds. Had I already done that, this submission would have been 14 bytes, because then the last three stages would have been reduced to a single one:
%'>O#`\d+

How is that like one eigth my size? Nice work.

@ThreeFx Because I don't use brute force. ;) Explanation coming in a minute.

><>, 46 43 35 + 4 for  -s= = 39 bytes
0&l?!v:3%?\&:n1+$o!
+nf0.>&n; >l&:@

This is an implementation of xnor's algorithm in ><>.
It takes the input string on the stack (-s flag with the standard interpreter).
You can try it out on the online interpreter.

<> seems like a fitting language for this challenge.

><>, 26 + 4 = 30 bytes
l22pirv
1+$2po>:3%::2g:n$-

Try it online! +4 bytes for the -s= flag - if just -s is okay (it would mean that the flag would need to be dropped entirely for empty input), then that would be +3 instead.
Assumes that STDIN input is empty so that i produces -1 (which it does on EOF). The program errors out trying to print this -1 as a char.
Uses the max-of-nums-so-far-for->, min-of-nums-so-far-for-< approach.
[Setup]
l22p         Place (length of stack) = (length of input) into position (2, 2) of
             the codebox. Codebox values are initialised to 0, so (0, 2) will
             contain the other value we need.
i            Push -1 due to EOF so that we error out later
r            Reverse the stack
v            Move down to the next line
>            Change IP direction to rightward

[Loop]
:3%          Take code point of '<' or '>' mod 3, giving 0 or 2 respectively
             (call this value c)
:            Duplicate
:2g          Fetch the value v at (c, 2)
:n           Output it as a number
$-1+         Calculate v-c+1 to update v
$2p          Place the updated value into (c, 2)
o            Output the '<' or '>' as a char (or error out here outputting -1)

A program which exits cleanly and does not make the assumption about STDIN is 4 extra bytes:
l22p0rv
p:?!;o>:3%::2g:n$-1+$2

CJam, 16 bytes
l_,),.\'</Wf%'<*

Try it online!
A port of my Retina answer.
Explanation
l    e# Read input.
_,   e# Duplicate, get length N.
),   e# Get range [0 1 2 ... N].
.\   e# Riffle input string into this range.
'</  e# Split around '<'.
Wf%  e# Reverse each chunk.
'<*  e# Join with '<'.

Perl, 29 bytes
Includes +2 for -lp
Run with input on STDIN, e.g.
order.pl <<< "<<><><<"

Output:
0<1<7>2<6>3<4<5

order.pl:
#!/usr/bin/perl -lp
s%%/\G</?$a++:y///c-$b++%eg

Explanation
Have two counters, max starting with the string length, min starting with 0. Then at each boundary (including start and end of string) if it is just before a < put the minimum there and increase by 1, otherwise put the maximum there and decrease by 1 (at the end of the string it doesn't matter which counter you take since they are both the same)

s{}{/\G/...} I've never seen that before, it's brilliant.

This is an old challenge, but you can shave a few bytes by adding a -F  switch and using 1+$#F-- instead of y///c-$b++: Try it online!

Python 2, 163 137 bytes
from random import*
def f(v):l=len(v)+1;N=''.join(sum(zip(sample(map(str,range(l)),l),v+' '),()));return N if eval(N)or len(v)<1else f(v)

Shuffles the numbers until the statement evals to True.
Try it.

This is clearly the most sensible of all answers.

Python 2, 67 bytes
f=lambda s,i=0:s and`i+len(s)*(s>'=')`+s[0]+f(s[1:],i+(s<'>'))or`i`

A recursive function. Satisfies each operator in turn by putting the smallest unused value x for x< and greatest for x>. The smallest unused value is stored in i and updated, and the largest unused value is inferred from i and the remaining length.

I think you could do (s>'=') instead of (s>='>') to save a byte?

@mathmandan Thanks! It's weird that < and > are not consecutive codepoints.

Agreed!  But I guess I can see how it would make sense to have = between < and >.

APL, 33 bytes
⍞←(S,⊂''),.,⍨-1-⍋⍋+\0,1-2×'>'=S←⍞

⍋⍋ is unusually useful.
Explanation
⍞←(S,⊂''),.,⍨-1-⍋⍋+\0,1-2×'>'=S←⍞
                                   ⍞ read a string from stdin      '<<><><<'
                                 S←   store it in variable S
                             '>'=     test each character for eq.   0 0 1 0 1 0 0
                         1-2×         1-2×0 = 1, 1-2×1 = ¯1         1 1 ¯1 1 ¯1 1 1
                                      (thus, 1 if < else ¯1)
                       0,             concatenate 0 to the vector   0 1 1 ¯1 1 ¯1 1 1
                     +\               calculate its running sum     0 1 2 1 2 1 2 3
                   ⍋                 create a vector of indices    1 2 4 6 3 5 7 8
                                      that sort the vector in
                                      ascending order
                 ⍋                   do it again: the compound ⍋⍋ 1 2 5 3 6 4 7 8
                                      maps a vector V to another
                                      vector V', one permutation of
                                      the set of the indices of V,
                                      such that
                                            V > V  => V' > V'.
                                             i   j     i    j
                                      due to this property, V and V'
                                      get sorted in the same way:
                                          ⍋V = ⍋V' = ⍋⍋⍋V.
              -1-                     decrement by one              0 1 4 2 5 3 6 7
      ⊂''                            void character vector         ⊂''
    S,                                concatenate input string     '<<><><<' ⊂''
   (     ),.,⍨                       first concatenate each        0 '<' 1 '<' 4 '>' 2 \
                                     element of the result vector  '<' 5 '>' 3 '<' 6 '<' \
                                     with the cordisponding        7 ⊂''
                                     element in the input string,
                                     then concatenate each result
⍞←                                  write to stdout

What do the Christmas trees (⍋⍋) do?

⍋ is grade up, which returns indicies in sorted order. By doing it twice, you get 1 where the smallest number was, 2 where the next smallest number was, ect.

@ConorO'Brien edited with a short explanation.

Yes, very short ._.

JavaScript (ES6), 74 56 bytes
s=>s.replace(/./g,c=>(c<'>'?j++:l--)+c,j=0,l=s.length)+j

Starts with the set of numbers 0...N. At each stage simply takes the greatest (l) or least (j) of the remaining numbers; the next number must by definition be less than or greater than that. Edit: Saved a massive 18 bytes thanks to @Arnauld.

Can you use replace? Maybe s=>s.replace(/./g,c=>(c<'>'?j++:l--)+c,j=0,l=s.length)+j

@Arnauld ...and I thought I was doing well to golf my first attempt (which wasn't amenable to replacement by replace) down to 74 bytes...

Pyth - 19 bytes
Hooray for comparison chaining!
!QZhv#ms.idQ.p`Mhl

Doesn't work online cuz of eval safety.

Jelly, 27 14 12 bytes
Port of @Martin Enders CJam solution
-2 bytes thanks to @Dennis
żJ0;µFṣ”<Uj”<

Test it at TryItOnline
How?
żJ0;Fṣ”<Uj”< - main link takes an argument, the string, e.g. ><>
 J           - range(length(input)), e.g. [1,2,3]
  0          - literal 0
   ;         - concatenate, e.g. [0,1,2,3]
ż            - zip with input, e.g. [[0],">1","<2",">3"]
    F        - flatten, list, e.g. "0>1<2>3"
      ”<  ”< - the character '<'
     ṣ       - split, e.g. ["0>1","2>3"]
        U    - upend (reverse) (implicit vectorization), e.g. ["1>0","3>2"]
         j   - join, e.g. "1>0<3>2"

Previous method was interesting mathematically, but not so golfy...
=”>U
LR!×ÇĖP€S‘
L‘ḶŒ!ị@ÇðżF

This uses the factorial base system to find an index of the permutations of [0,N] that will satisfy the equation.

U vectorizes, so you don't need €. żJ0; saves another byte.

Java 8, 126 125 bytes
s->{int t=s.replaceAll("<","").length(),y=t-1;String r=t+++"";for(char c:s.toCharArray())r+=(c+"")+(c<61?t++:y--);return r;};

I don't think this even works hehe
Ungolfed test program
public static void main(String[] args) {
    Function<String, String> function = s -> {
        int t = s.replaceAll("<", "").length(), y = t - 1;
        String r = t++ + "";
        for (char c : s.toCharArray()) {
            r += (c + "") + (c < 61 ? t++ : y--);
        }
        return r;
    };

    System.out.println(function.apply("<<><><<"));
    System.out.println(function.apply(">>><<<"));
    System.out.println(function.apply(">>>"));
    System.out.println(function.apply("<<<"));
    System.out.println(function.apply(">><><>>"));
}

You can change the .replaceAll to .replace and remove the parenthesis around (c+"") to save 5 bytes.

@KevinCruijssen Not arsed about 5 bytes hahah.

When using a proper golfing language, 5 bytes is the difference between 5th and 2nd place. With java it's the difference between last place by far and just last place.

Java will almost always be last with code-golfing challenges, but the reason we post Java answers to begin with is for the fun of writing it as short as possible. I personally am already happy if my Java code goes from 500 to 499 in terms of byte. ;P

We basically ignore all over competitors and just compete with or Java/ C# submissions etc..

Clojure, 152 132 126 bytes
(defn f[s](loop[l 0 h(count s)[c & r]s a""](if c(case c\<(recur(inc l)h r(str a l c))(recur l(dec h)r(str a h c)))(str a l))))

Saved a fair number of bytes by eliminating as much whitespace as I could. I realized whitespace isn't necessary to separate a parenthesis from another character.
Basically a Clojure port of @Scepheo's answer. Works identically.
Those recur calls are killer! I suppose I could have used atoms to clean it up. The swap! calls required to use atoms added to the count :/
Thanks to @amalloy for saving me a few bytes.
Ungolfed:
(defn comp-chain [chain-str]
  (loop [l 0 ; Lowest number
         h (count chain-str) ; Highest number
         [c & cr] chain-str ; Deconstruct the remaining list
         a ""] ; Accumulator
    (if c ; If there's any <>'s left
      (if (= c \<) ; If current char is a <...
        (recur (inc l) h cr (str a l c)) ; Add l to a, and inc l
        (recur l (dec h) cr (str a h c))) ; Add h to a, and dec h
      (str a l)))) ; Add on the remaining lowest number, and return

Welcome to the site!

@DJMcMayhem Thanks. Hopefully next time I'll be able to come up with my own solution instead of just porting another answer.

You can save two more spaces in the loop binding, before s and after a. You could also shave a bit by replacing the if tree with a case: (case c \< (recur ...) nil (str ...) (recur ...)). And of course cr could be a shorter name.

@amalloy Good points, thank you. I'll update when I get on my laptop.

2sable, 20 bytes
gUvy'<Qi¾¼ëXD<U}y}XJ

Explanation
gU                     # store input length in variable X
  v              }     # for each char in input
   y'<Qi               # if current char is "<"
        ¾¼             # push counter (initialized as 0), increase counter
          ëXD<U}       # else, push X and decrease value in variable X
                y      # push current char
                  XJ   # push the final number and join the stack

Try it online!
For N<10 this could have been 14 bytes:
ÎvyN>}J'<¡í'<ý

C#, 102 99 bytes
string f(string s){int i=0,j=s.Length;var r="";foreach(var c in s)r=r+(c<61?i++:j--)+c;return r+i;}

Ungolfed:
string f(string s)
{
    int i = 0, j = s.Length;    // Used to track the lowest and highest unused number.
    var r = "";                 // Start with the empty string.

    foreach (var c in s)        // For each character in the input string:
        r = r +                 // Append to the result:
            (c < 61             // If the current character is '<':
                ? i++           // Insert the lowest unused number,
                : j--)          // otherwise, insert the highest unused number.
            + c;                // And append the current character.

    return r + i;               // Return the result with the last unused number appended.
}

I'm tired, so I could be missing something, but wouldn't changing the r = r + part to a compound assignment save a couple bytes?

No - the r+ part on the right-hand side tells the compiler the entire thing is a string, so the string representation of c is used. If I used r+=, the ?: part would evaluate to an int, the ordinal value of c would be added to that and only then would it be converted to its string representation.

Haskell, 162 bytes
import Data.List
(a:b)%(c:d)=show c++a:b%d
_%[x]=show x
f l=map(l%).filter(l#)$permutations[0..length l]
(e:f)#(x:y:z)=(e!x)y&&f#(y:z)
_#_=0<1
'>'!x=(>)x
_!x=(<)x

This is friggin' long.

Perl (107 + 1 for -p) 108
for$c(split''){$s.=$i++.$c;}
for$b(split'<',$s.$i){$h[$j]=join'>',reverse split'>',$b;$j++;}
$_=join'<',@h;

Algorithm stolen from Martin Ender♦'s answer

05AB1E, 13 12 bytes
õª€N'<¡íJ'<ý

Port of @MartinEnder's CJam answer, so make sure to upvote him as well!
-1 byte thanks to @Grimmy.
Try it online or verify all test cases.
Explanation:
õª            # Append an empty string to the (implicit) input-string as list,
              # which also converts the input-string to a list of characters
              #  i.e. "><>" → [">","<",">",""]
  €N          # Insert the 0-based index before each character in this list
              #  → [0,">",1,"<",2,">",3,""]
    '<¡      '# Split this list on "<"
              #  → [[0,">",1,],[2,">",3,""]]
       í      # Reverse the items of each inner list
              #  → [[1,">",0],["",3,">",2]]
        J     # Join each inner list into a string
              #  → ["1>0","3>2"]
         '<ý '# And join this list of strings with "<" delimiter
              #  → "1>0<3>2"
              # (after which the resulting string is output implicitly as result)

€NIgª => õª€N for -1: TIO. Ć€N¨ also works.

@Grimmy Thanks, smart golfs.

Python 2, 176 172 bytes
It's not very short compared to the others, but I'm happy that I solved it so quickly.
from itertools import*
def f(s):
 for p in permutations(range(len(s)+1)):
    n=list(s);p=list(p);t=[p.pop()]+list(chain(*zip(n,p)));r="".join(map(str,t))
    if eval(r):return r

Try it online
Ungolfed:
from itertools import*
def f(s):
    n=list(s);R=range(len(s)+1)
    for p in permutations(R):
        p=list(p)
        r=[p.pop()]
        t=n+p
        t[::2]=n
        t[1::2]=p
        r="".join(map(str,r+t))
        if eval(r):return r

Try it online

the interlace part can prolly be much shorter done through zip

@Maltysen Not a ton shorter, because the lists aren't the same length (I still have to pop), but it is a bit shorter. If N<10, I could make stringifying shorter.

Ruby, 135 bytes
g=gets
puts g.nil?? 0:[*0..s=g.size].permutation.map{|a|a.zip(g.chars)*""if s.times.map{|i|eval"%s"*3%[a[i],g[i],a[i+1]]}.all?}.compact

Note: Time complexity is large (O(n!)).

PHP , 190 Bytes
random shuffle till a valid solution exists
$x=range(0,$l=strlen($q=$argv[1]));while(!$b){$b=1;$t="";shuffle($x);for($i=0;$i<$l;){$t.=$x[$i].$q[$i];if(($q[$i]==">"&$x[$i]<$x[$i+1])|($q[$i]=="<"&$x[$i]>$x[1+$i++]))$b=0;}}echo$t.$x[$i];

381 Bytes get all solutions and pick one
<?php $d=range(0,strlen($q=$argv[1]));echo $q."\n";$e=[];function f($t=""){global$e,$d,$q;foreach($d as$z){preg_match_all("#\d+#",$t,$y);if(in_array($z,$y[0]))continue;$p=preg_match_all("#[<>]#",$t);$g="";if(preg_match("#\d+$#",$t,$x)){if(($q[$p]==">"&$x[0]<$z)|($q[$p]=="<"&$x[0]>$z))continue;$g=$q[$p];}strlen($q)==$p+1|!$q?$e[]=$t.$g.$z:f($t.$g.$z);}}f();echo$e[array_rand($e)];

Javascript (node.js), 94 bytes
Try it online
s=>[[0],...s].reduce((x,v,i)=>v>'<'?[...x.map(v=>v+1),0]:[...x,i]).reduce((x,v,i)=>x+s[i-1]+v)

Ungolfed:
s =>
  [[0],...s].reduce((x, v, i) =>
    v > '<' ?
      [...x.map(v => v + 1), 0] :
      [...x, i])
    .reduce((x, v, i) => x + s[i-1] + v)

Haskell, 95 bytes
s=show
('<':y)!(a:b)=s a++'<':y!b
(x:y)!z=s(last z)++x:y!init z
_!(y:_)=s y
f x=x![0..length x]

Try it online!

Burlesque, 38 bytes
sarzPp{J'>=={PPl_}{PPg_j}x/iePp}]mPP?+

Try it online!
Using xnor's algorithm
sarz                      # Generate range [0,N_comp]
Pp                        # Push this into state stack
{
 J'>==                    # Non destructive test if is ">"
 {PPl_}{PPg_j}x/ie        # If it is, take the head of the range
                          # Else take the tail
 Pp                       # Push the remainder back to the state stack
}]m                       # Apply to each character and map result to string
PP                        # Take the remaining element from state stack
?+                        # Append it to the string

Burlesque, 61 bytes
)'.2co)PIsarzr@{2CO}m[jbcz[{**FL(&&)[+}^m:e!{~]3co{x/}^mgn}m[

Try it online!
A method using actually evaluating permutations of ints, longer partially due to trying to format the final answer sensibly.
)'.     # Add a "." before each character (.> is comparison in Burlesque)
2co)PI  # Split into comparison operators
sarzr@  # Create all permutations of [0,N_comp]
{2CO}m[ # Create ngrams of length 2 ({abc} -> {ab bc}
jbcz[   # Zip with the operators
{
 **FL   # Merge to form an operation of the form {a b .> b c .<}
 (&&)[+ # Append a bitwise and
}^m     # Apply to each element
:e!     # Filter for those which when evaluated produce true
{
 ~]     # Drop last element (&&)
 3co    # Split into chunks of three
 {x/}^m # Cycle and push each block
 gn     # Delete duplicate consecutive elements
}m[     # Apply to each group

PHP, 165 156 110 bytes
$o=[$j=$i=$s=$m=0];for(;$i<strlen($n=$argn);)$o[]=$n[$i++]=='<'?++$m:--$s;for(;$j<=$i;)echo$o[$j]-$s,$n[$j++];

Try it online!
Ungolfed
<?php

$min=0;
$max=0;
$current=0;

$order = [0];

for ($i=0;$i<strlen($argn);$i++){
    $compare=$argn[$i];
    if ($compare=='<') {
        $max++;
        $current=$max;
    } else {
        $min--;
        $current=$min;
    }
    $order[] = $current;
}

for ($i=0;$i<=strlen($argn);$i++){
    echo ($order[$i]-$min);
    if ($i<strlen($argn)) echo $argn[$i];
}

Excel (Ver. 1911), 199 Bytes
Using iterative calculation (max iterations set to 1024)
B2 'Input
B3 =IF(B3=4^5,1,B3+1)
B4 =B3-1
C2 =SEQUENCE(LEN(B2))
D2 =ROW(C2#:C1)-1
E2 =IF(B4,IF(C2#=B4,IF(F2#=">",@SORT(G2#,,-1),G2),E2#),-C2#)
F2 =MID(B2,C2#,1)
G2 =FILTER(D2#,NOT(MMULT(N(D2#=TRANSPOSE(E2#)),C2#/C2#)))
H2 =CONCAT(E2#:F2#,G2) ' Output

Explanation
B2 'Input
B3 =IF(B3=4^5,1,B3+1) ' Keeps track of iteration number
B4 =B3-1 ' 0 index the iteration counter
C2 =SEQUENCE(LEN(B2)) ' Generate sequence to index input string
D2 =ROW(C2#:C1)-1 ' Create sequence [0..N]
E2 =IF(B4,IF(C2#=B4,IF(F2#=">",@SORT(G2#,,-1),G2),E2#),-C2#)
      ' On each iteration check if the current char is ">" pull the largest unused number,
      ' else pull the smallest
F2 =MID(B2,C2#,1) ' Break the input string into separate rows
G2 =FILTER(D2#,NOT(MMULT(N(D2#=TRANSPOSE(E2#)),C2#/C2#))) ' Set of unused numbers
H2 =CONCAT(E2#:F2#,G2) ' Concatenate numbers, gt/lt signs, and last unused number

Test Sample

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/


text:
HexaGolf: Rotatagons
See also: Wordagons
Challenge
Given a hexagon and a number n as input, output the same hexagon rotated n times.
Hexagon
The hexagon will be a string like so:
  a b c
 d d e e
f f o g g
 h h i i
  j k l

The hexagon will always be regular and will only ever contain the printable ASCII characters:
 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

Rotation
To find how much to rotate the hexagon by, multiply n by 60 degrees to get the angle of rotation. For example, using the above hexagon, if n is 2, we multiply that by 60 to get 120 degrees. Then, we rotate the hexagon by 120 degrees:
  j h f
 k h f d
l i o d a
 i g e b
  g e c

Note that each side has moved two sides clockwise.
If n is positive, you should rotate the hexagon clockwise. If n is negative, you should rotate the hexagon anticlockwise.
n will always be an integer in the range -6 to 6 inclusive.
Examples
Input:
  . u .
 .  |  .
l - + - r
 .  |  .
  . d .

n = 3
  . d .
 .  |  .
r - + - l
 .  |  .
  . u .

Input:
  - - -
 /     \
<       >
 \     /
  - - -

n = -1
Output:
  - \ >
 -     /
-       -
 /     -
  < \ -

Input:
   h e x a
  g o n s a
 n d t r i a
n g l e s m a
 k e m e s a
  d l y m a
   d d e r

n = 6
Output:
   h e x a
  g o n s a
 n d t r i a
n g l e s m a
 k e m e s a
  d l y m a
   d d e r

Winning
The shortest program in bytes wins.

What do you have against triangles? :P

@ConorO'Brien Haven't you seen how dangerous their points are? ;)

Can we take input as a list of lines? Can we assume input is space-padded?

@Lynn Yep, a list of lines is fine and it will be padded

Very closely related: http://codegolf.stackexchange.com/q/51964/15599

@LevelRiverSt This challenge does support negative integers though

Well, you can just repeat the code n%6 times.

I lost a few minutes trying to be a smartass with CSS' transform:rotate(x). Turns out that wasn't a bright idea, who would have known?

I know you have space in your possible character list, but do we really need to support characters that are the same as the background character ? Having to use coordinates makes all my solutions a lot longer

@TonHospel Yes, you need to support hexagons like this and this

@BetaDecay Would I be allowed to remove t.up() in my program? It leaves extra "pen lines" on the canvas where the turtle moves.

@mbomb007 Hm, sorry, but since it's an ascii art challenge, no

Perl, 120 119 113 107 104 102 bytes
Includes +6 for -0pXi
Run with the hexagon on STDIN (padded with spaces so all lines have the same length) and the number of rotations after -i.
perl -0pXi1 rotagon.pl
  a b c
 d d e e
f f o g g
 h h i i
  j k l
^D

rotagon.pl
s!(.)!$X=(3*($w=y/
//*2)/4+($-="@-"/$w)-"@+"%$w)/2*--$w+2*$--.25;/^\C{$X}(.)/;$1!eg while$^I--%6

Finally got the rotation matrix to be shorter than the old double loop

I had to add the a and n flags to get this to work.

@Neil That is only needed on old perl versions. In recent perls -F implies -a and -a in turn implies -n

Python 2, 160 158 156 148 124 bytes
Prepare to be amazed! The resulting text is drawn on a canvas... by a Turtle! :D
from turtle import*
h,n=input()
up()
rt(n*60)
l=0
for c in h:
 write(c);fd(9);l-=1
 if" ">c:fd(9*l);rt(90);fd(15);lt(90);l=0

Try it online - Supports decimal rotations as well!

If you would prefer the turtle to be shaped like one, you can add the line t.shape("turtle").
View the revision history to see past versions.
Aliases used:
up() - penup()
rt() - right()
lt() - left()
fd() - forward()
bk() - backward()
Thanks to Sherlock9 for the suggestions!

7 more until you beat standard python!

@EasterlyIrk If only t.write('\n') worked...

@EasterlyIrk If I could remove t.up(), I'd be there.

Congrats! You are beating normal python!

Python 2.7, 151 bytes
h,n=input()
s=1-len(h)
e=enumerate
exec n%6*"h=[''.join(c>' 'and h[y-x-3*s/2>>1][x*2+y*6+s>>2]or c for x,c in e(l))for y,l in e(h)];"
print'\n'.join(h)

Example:
% python2.7 hexarot.py <<<'[["   h e x a   ","  g o n s a  "," n d t r i a ","n g l e s m a", " k e m e s a ","  d l y m a  ","   d d e r   "],-1]'
   a a a a
  x s i m a
 e n r s s a
h o t e e m r
 g d l m y e
  n g e l d
   n k d d

@mbomb007 That won't work because of the order of operations, the subtractions will happen before the bitshift.

JavaScript (ES6), 130 127 bytes
f=(s,n)=>n%6?f(s.split`
`.map((s,i,a)=>s.replace(/./g,(c,j)=>(a[(i+z-j)/2+z]||c)[(i+j-z)/2+i]||c,z=a.length>>1)).join`
`,n-1):s

Originally based on my answer to Rotate a diamond tiling although I might now be able to rewrite that answer along the lines of this answer.


text:
Marcel Proust and Markov decipher security service’s T9 texts
As if this challenge could be any more Pythonesque in spirit... No prior knowledge of Markov chains or encryption techniques is required.
You are a spy who needs to obtain some crucial information from the British security service M1S. The agents of M1S are well aware that their Wi-Fi signals can be intercepted, their Android/iOS security vulnerabilities exploited etc., so all of them are using Nokia 3310’s to transmit text information which is typed using the T9 auto-completion.
You had previously hacked the phones to be delivered to the intelligence agency and had installed keyloggers under their glorious plastic keyboards, so now you receive sequences of numbers corresponding to the letters they typed, so “the eagle has left the nest alert the agents” becomes
84303245304270533808430637802537808430243687

But wait! Some T9 sequences are ambiguous (“6263” could be “name”, “mane” or “oboe”; the more obscure, the more suspicious it gets!), so what do you do? You know that the only entrance examination M1S uses is summarising Marcel Proust’s masterpiece “Remembrance of Things Past” in 15 seconds, so you want to pick the word that comes next after the previous one according to its frequency distribution in the entire chef-d’œuvre of Proust!
Can you crack the code and obtain what could be the original message?
The principle of T9

The T9 auto-completion mechanism can be described as follows. It maps alphabetic characters to numbers as shown on the picture above.
abc     -> 2
def     -> 3
ghi     -> 4
jkl     -> 5
mno     -> 6
pqrs    -> 7
tuv     -> 8
wxyz    -> 9
<space> -> 0
<other> -> <is deleted>

The T9 decryptor receives a sequence of digits and tries to guess the word that could be typed with those keypresses. It might use a standard frequency table, but we are going one step further and predicting the next word using a Markov chain!
Learning sample
The corpus is this heavily stripped version of Proust’s “Remembrance of Things Past” (s/-/ /g, s/['’]s //g and s/[^a-zA-Z ]//g — begone confusing possessive 's!) originally published on the University of Adelaide website (the text of this work is in the Public Domain in Australia).
The whole text must be analysed as one string, as one long sentence, as one long vector of words (whichever is more convenient for your language), stripped of linebreaks, and split into words at spaces. (I do not supply a single-paragraph file because such might be frowned upon by github tools.)
How do I read the whole text as one string / sentence? An example in R:
p_raw  <- read.table("proust.txt", sep="\t") # Because there are no tabs
p_vec  <- as.character(p_raw$V1)       # Conversion to character vector
p_str  <- paste(p_vec, collapse=" ")   # One long string with spaces
p_spl  <- strsplit(p_str, split=" ")[[1]] # Vector of 1360883 words
proust <- p_spl[p_spl!=""]           # Remove empty entries — 1360797

Task
Given a sequence of digits as a number, return a possible text string that could be typed using the corresponding T9 keys using a probabilty chain to predict the next word X based on this training text treated as one long sentence.
If X is the first T9-word of the text and there are multiple guesses, pick one at random, otherwise pick the only one possible.
For all subsequent T9-words X(i) preceded by a word already deciphered w(i-1):

If a T9-word X can be converted into a normal word x in one unique way, do it.
If there are multiple conversion options available for X, say x1, x2, ..., look up the preceding guessed word w.

If w is never followed by anything that maps to X in the original work of Proust, pick any of the possible x1, x2, ... at random.
If w X always corresponds to w x1 in the original and there are no concurrent xi’s that could be mapped into X, pick x1.
If w X can be converted to w x1, w x2, ... that can be found in the corpus, then count all possible xi’s that follow w and map to X in the corpus and pick xi with probability xi/(x1 + x2 + ...).

Example 2a. If the message is 76630489, where 489 could be guy or ivy (they occur in the corpus at least once), 7663 can be deciphered as some (a very probable first word). If some is never followed by anything that maps to 489 in the corpus, then pick guy or ivy at random with probability 0.5.
Example 2b. If the message is 766302277437, where 2277437 could be barrier or carrier, 7663 can be deciphered as some. If Proust always used some carrier and never some barrier, then pick some carrier.
Example 2c. Suppose that you want to decipher the sequence 536307663. 5363 was predicted as lend. 7663 could be any of these: pond, roof and some. You count the occurrences of the word following lend in the sample corpus. Suppose you get something like this (just to illustrate):
        T9  Word following lend  Occurrences
      7663  some                           7
      7663  pond                           2
      7663  roof                           1

So if 7663 is preceded by lend, there is 7/(7+2+1)=70% probability that 7663 stands for some, 20% pond and 10% roof. Your algorithm should produce lend some in 70% cases, lend pond in 20% cases etc.
You may safely assume that the agents use only a-z letters and spaces (no punctuation marks, no possessive 's, and no numbers).
You may also assume that the agents of M1S never use any words outside the scope of “Remembrance of Things Past” (which is a whopping vocabulary of 29,237 words!).
The T9 fuctionality was implemented in this challenge, so you might have a look at it.
If you need any help, probabilistic chains were gloriously tamed in this, that and the following challenges, but you do not even need to know the principle of such chains: everything is stated in the task.
Test cases
--Inputs--
20784250276960369
20784250276960369
84303245304270533808430637802537808430243687
94280343084306289072908608430262780482737
94280343084306289072908608430262780482737

--Possible outputs--
c quick brown fox
a stick crown fox
the eagle gas left the nest blest vie agents
what did the navy pay to the coast guards
what did the navy raz un the coast guards

Rules:

Standard loopholes apply.
You do not know the original message, all you get is a sequence of digits and the file proust.txt that you just need to load in the memory / workspace / whatever. There is no need to have anything self-contained; assume proust.txt is always accessible.
Your algorithm must be able to produce different outputs with respective probabilities if more than one decryption option is probable according to the corpus (see Example 2c).

You need to stay as discreet as possible, so the shortest code wins!
P.S. The obvious benefit of this probabilistic algorithm is the fact that the probability you will get a true original string for an ambiguous deciphered string tends to one — just wait...
P.P.S.  See also Prediction by Partial Matching.

Peter Taylor’s remarks from the sandbox were taken into account. Sadly, very few people responded during the week it had been posted there despite multiple updates, so any suggestions are welcome! BTW, this is my first challenge!

I suspect that a big reason you didn't get many responses is because of the advanced knowledge needed to understand this problem.  If you are wanting this challenge to appeal to a larger crowd, I'd recommend including some earlier examples that show the markov chain at work :)

@NathanMerrill OK, I added 3 links to sample challenges. However, a user need not know Markov chains at all because the task is described in the question body as algorithmically as possible: if X, do Y with probabilities obtained by calculating Z in this learning sample. I tried to make it as self-sufficient as it gets...

Oh, I understand.  If you didn't explain it, I would have voted to close it.  It just looks like it needs advanced knowledge :)

@NathanMerrill Well, verbosity will kill me some day...

I like this challenge, but I haven't had time to sit down and create/golf a solution yet. Hopefully that will happen soon.

Reference that might be of interest for this challenge: Prediction by Partial Matching

IMHO, a dictionary of 29K words looks excessive for this format. It's already more than 100K once zipped and I don't feel like building a trie or a DAG on so many entries. I'd suggest to limit the training text to a few relevant paragraphs.

@Arnauld Referenced that PPM article. However, the dictionary must be so huge because of the rule 2c: if there are multiple decryption options possible and such sequences had occurred in the text before... There is very low probability that the exact two words go enought times one after another in the learning text (except such popular cases as “said to”). Proust never wrote “brown fox”. I wish I could make the learning sample larger just to estimate the probabilities of the real-world language and thought “RoTP” was big enough (in fact, it is not... where’s my “brown fox”, then?).

Are we expected to encode the data from the Proust corpus into our solution?  Given the size of the text file, that would seem to bias the solutions toward data compression rather than the word selection aspects of the task.  On the other hand, it the text file is an assumed input, the solutions could focus on building and using a data structure to perform the   steps as stated in the task.

@RootTwo No, no! It will suffice to provide a function that outputs the deciphered text on the fly. You are encouraged to read and find occurrences in proust.txt only as a necessary step for prediction... there is no need to output a data structure, a matrix of probabilities or a matrix of follow-ups and precedences between any two words. Your function may “forget” what it had calculated after outputting a string. Seems that I should post my own (non-competing) solution in order to encourage other people...

@Andrei My solution is a function of two parameters, the message to decode and the file name of the corpus ("proust.txt").  It reads the corpus and then decodes and prints the message.  My question was whether that would be an acceptable answer.  Can the solution read proust.txt or does the solution need to be self contained?

@RootTwo I should update the specification: the solution may read proust.txt — and in fact it should. Therefore, you may treat the file proust.txt as a pre-existing set of strings that you just need to load in the memory / workspace / whatever. There is no need to have anything self-contained; assume proust.txt is always accessible.

R solution, non-competing illustration of what can be done
Firstly, we load the sequence of words into the memory:
p_raw  <- read.table("proust.txt", sep="\t") # Because there are no tabs
p_vec  <- as.character(p_raw$V1)       # Conversion to character vector
p_str  <- paste(p_vec, collapse=" ")   # One long string with spaces
p_spl  <- strsplit(p_str, split=" ")[[1]] # Vector of 1360883 words
proust <- p_spl[p_spl!=""]           # Remove empty entries — 1360797

Secondly, we need a function that T9-ifies any text:
t9 <- function (x) {
  x <- chartr(paste(c(letters, " "), collapse=""), "222333444555666777788899990", tolower(x))
  x <- gsub("[^0-9]", "", x, perl = TRUE) # Safety check
  x <- x[x!=""] # Also for safety because... you know...
  x
}

Then, we T9-ify Proust:
p9 <- t9(proust)

Final preparation: we split the input string at zeros using a function that we call prep):
prep <- function (x) {
  x <- chartr("0", " ", x)
  x <- strsplit(x, " ")[[1]]
  x <- x[x!=""] # Boil the empty strings for safety
  x
}

And now I propose a function that takes any input string of numbers, preps it and deciphers the words one by one:
decip <- function(x, verbose = FALSE) {
  x <- prep(x)
  l <- length(x)
  decrypted <- rep(NA, l)
  tb <- table(proust[which(p9 == x[1])])
  decrypted[1] <- sample(names(tb), 1, prob=tb/sum(tb))
  if (verbose) print(decrypted[1])
  for (i in 2:l) {
    mtchl <- p9 == x[i]
    mtch <- which(mtchl)  # Positions that matched
    pmtch <- proust[mtch] # Words that matched
    tb <- table(pmtch)    # Count occurrences that matched
    if (length(tb)==1) {  # It is either 1 or >1
      decrypted[i] <- names(tb)[1]
      if (verbose) print(paste0("i = ", i, ", case 1: unique decryption"))
      } else {  # If there are more than one ways to decipher...
      preced <- proust[mtch-1]
      s <- sum(preced==decrypted[i-1])
      if (s==0) {
        decrypted[i] <- sample(names(tb), 1)
        if (verbose) print(paste0("i = ", i, ", case 2a: multiple decryption, collocation never used, picking at random"))
        } else {
        tb2 <- table(pmtch[preced==decrypted[i-1]])
        if (length(tb2)==1) {
          decrypted[i] <-  names(tb2)[1]
          if (verbose) print(paste0("i = ", i, ", case 2b: multiple decryption, only one collocation found, using it"))
        } else {
          decrypted[i] <- sample(names(tb2), 1, prob = tb2/sum(tb2))
          if (verbose) print(paste0("i = ", i, ", case 2c: multiple decryption, ", length(tb2), " choices"))
          }
      }
    }
    if(verbose) print(decrypted[i])
  }
  decrypted
}

And now what it is actually doing:
decip("20784250276960369", verbose=TRUE)
----
[1] "a"
[1] "i = 2, case 2c: multiple decryption, 2 choices"
[1] "quick"
[1] "i = 3, case 2a: multiple decryption, collocation never used, picking at random"
[1] "brown"
[1] "i = 4, case 1: unique decryption"
[1] "fox"
[1] "a"     "quick" "brown" "fox"

Second example:
decip("84303245304270533808430637802537808430243687", verbose=TRUE)
----
[1] "what"
[1] "i = 2, case 2b: multiple decryption, only one collocation found, using it"
[1] "did"
[1] "i = 3, case 2b: multiple decryption, only one collocation found, using it"
[1] "the"
[1] "i = 4, case 1: unique decryption"
[1] "navy"
[1] "i = 5, case 2a: multiple decryption, collocation never used, picking at random"
[1] "raz"
[1] "i = 6, case 2a: multiple decryption, collocation never used, picking at random"
[1] "um"
[1] "i = 7, case 2a: multiple decryption, collocation never used, picking at random"
[1] "the"
[1] "i = 8, case 2b: multiple decryption, only one collocation found, using it"
[1] "coast"
[1] "i = 9, case 1: unique decryption"
[1] "guards"
[1] "what"   "did"    "the"    "navy"   "raz"    "um"     "the"    "coast"  "guards"

Please do not comment that this can be golfed. Seems that few people are interested in this challenge because of my terrible verbosity, so I posted this answer to show what a possible programme could look like. You need not upvote/downvote this answer.

Python 3, 316 bytes
from random import*
from collections import*
def d(s,f):
 D=defaultdict(Counter);p=q=''
 for w in open(f).read().split():D[w.translate({97+c:(c-(c>17)-(c>24))//3+50for c in range(26)})].update([w]);D[p].update([w]);p=w
 for c in s.split('0'):q=choice([*(len(D[c])>1and D[c]&D[q]or D[c]).elements()]);print(q,end=' ')