Rubik's Cube Scrambles
C,129
f(){int i,n,m,r,s,t;for(i=26;i--;i&lt;25&amp;&amp;printf(&quot;%c%c&quot;,&quot;URFDLB&quot;[s%6],&quot;'2&quot;[r%3])){for(n=m,t=1;t;t=m*n==9)m=(r=rand()%15)/3+1;s+=m;}}

The inner loop generates a value of m in the range 1..5 which when added to s and taken modulo 6, ensures that no two consecutive moves are on the same side of the cube. The old value of m is stored in n and the test m*n==9 ensures that the value m=3 is never generated twice in a row (so opposite faces cannot be picked twice in a row; note the order of faces in the string.)
The least significant part of r is used to decide which suffix (', 2 or null) to use, taking advantage of the null character at the end of &quot;'2&quot;.
The outer loop runs 26 times. The first time, U can never be picked, so printf is suppressed for the first iteration.
Ungolfed code in test program
The ungolfed code puts a space between each move for clarity (the golfed code does not, in order to save one byte.) Additionally the golfed code saves a semicolon by relocating the printf within the for bracket.
f(){
  int i,n,m,r,s,t;
  for(i=26;i--;){
    for(n=m,t=1;t;t=m*n==9)m=(r=rand()%15)/3+1;
    s+=m;
    i&lt;25&amp;&amp;printf(&quot;%c%c &quot;,&quot;URFDLB&quot;[s%6],&quot;'2&quot;[r%3]);
  }
}

main(){
  int j;
  srand(time(0));
  for(j=0;j&lt;5;j++)f(), puts(&quot;&quot;);
}

Typical output
U' B D2 B' R' L F' D2 B D2 B2 R' B2 U D2 F' R U R' L B' L R2 B2 F'
U B U B F L2 D2 B' U' L B L R' D B U' D R D' B' F2 D' B D R
L D F2 B2 R' U F B' D2 L U R' L' U2 F' R F D U2 B L' B' U L2 F'
R2 B' F2 R2 L2 F' U2 L U' B' F R' D' F2 D F' L2 U2 R' D' B2 D F R2 L'
U2 F2 B2 D' F D F R L2 U' B D2 L' R D R F2 R' F2 U2 D R' D2 L F2