My python one-liner scramble generator

How is that relevant?
If 10 peoples' cubes are scrambled with the same algorithm, and any state can be reached in 25 moves, then everyone's puzzle should be well-scrambled just as if they were scrambled with a random first face. No?

That's about good as reasoning that since a 20 random-move scramble can reach any state, it should be a random state.

But in practice, doesn't really matter. We use random-state where it counts, and I hope someday it will be no problem to use MRSS everywhere.
 
Here is one written in Qbasic.
How to add output to a file, I leave as an exercise.

RANDOMIZE TIMER
CLS
A$ = "UDFBLR '2"
FOR T = 1 TO 10
V$ = ""
FOR S = 1 TO 25
BAD:
M$ = MID$(A$, INT(RND * 6) + 1, 1)
T$ = MID$(A$, ((INT(RND * 3) + 1) + 6), 1)
IF M$ = N$ THEN GOTO BAD
V$ = V$ + M$ + T$ + " "
N$ = M$
NEXT S
PRINT V$: PRINT
NEXT T

Download for qbasic here:
http://www.qbcafe.net/qbc/english/download/compiler/qbasic_compiler.shtml

A download for a up todate qbasic:
http://www.qb64.net/forum/index.php?PHPSESSID=03qhel8uvgmucik5jqcgd391r5&
 
Anyone want to make a nice scrambler for the motorola w180?
I can't find any documentations for it. Its java I guess...
 
My code for a 5x5 scrambler for TI-83/84:
Code:
:ClrHome
:Clrdraw
:AxesOff
:FnOff
:"URFDLBw '2→Str0
:0→C
:0→E
:0→F
:For(A,1,60,6
:For(B,1,97,14
:D→E
:C→D
:F→G
:randInt(7,8→F
:While C=D
:randInt(1,6→C
:While C=E and C-3=D or C+3=D
:randInt(1,6→C
:End
:If C=D and F≠G and C≠E
:10→C
:End
:If C=10
:D→C
:Text(A,B,sub(Str0,C,1)+sub(Str0,F,1)+sub(Str0,randInt(8,10),1
:End
:End

I'll try to find mine for 3x3.
 
Down to 212 characters thanks to Devin:
Code:
function r(x){return Math.floor(Math.random()*x)}function s(){var d=b=j=c=a=4;for(;j<29;j++){while(a==c&&d&b){a=r(3);b=r(2)+1}if(a!=c)d=0;c=a;d+=b;document.write("RLFBUD".charAt(a*2+b-1)+" 2'".charAt(r(3))+" ")}}

(JavaScript isn't the greatest for code golf, but it's pretty cool to make a tiny webpage that scrambles.)
 
120 chars.

Code:
map{while(($m=int rand 6)==$b||($c+$b==5&&$c==$m)){}print qw(U R F B L D)[$m].qw( ' 2)[int rand 3]." ";$c=$b;$b=$m}1..25

But yeah, like Lucas said, I'm sure there's a bunch of people who could destroy this, since mine is pretty basic.

Edit: 115

Code:
map{$m=int rand 6while$c+$b==5&&$c==$m||$m==$b;print qw(U R F B L D)[$m].qw( ' 2)[int rand 3]." ";$c=$b;$b=$m}1..25

>_>

Stefan. I'm sure you made a short one earlier, but i forgot where ... Enlighten us pls!!

Per
 
Down to 212 characters thanks to Devin:
Code:
function r(x){return Math.floor(Math.random()*x)}function s(){var d=b=j=c=a=4;for(;j<29;j++){while(a==c&&d&b){a=r(3);b=r(2)+1}if(a!=c)d=0;c=a;d+=b;document.write("RLFBUD".charAt(a*2+b-1)+" 2'".charAt(r(3))+" ")}}

Some improvements ...
179 characters.

Code:
function r(n){if(n)return Math.floor(Math.random()*n);for(d=b=j=c=a=4;j++<29;){for(;a==c&&d&b;b=r(2)+1,a=r(3));d=a!=c?b:d+b;c=a;document.write(" RLFBUD"[a*2+b]+" 2'"[r(3)]+" ")}}

just call r() with no args.
 
I have improved my TI 83/84 3x3 Scrambler and here it is...

183 characters
Code:
:ClrHome
:"URFBLD '2→Str0
:6→S
:0→F
:For(A,1,5,1
:For(B,1,14,3
:P→L
:F→P
:randInt(1,S→F
:randInt(7,9→T
:While F=P
:randInt(1,S→F
:End
:If L=T
:6→T
:If F+P=7
:Then
:5→S
:Else
:6→S
:End
:Output(A,B,sub(Str0,F,1)+sub(Str0,T,1
:End
:End

EDIT: 181 characters
Code:
:ClrHome
:"URFBLD '2→Str0
:6→S
:0→F
:For(A,1,5,1
:For(B,1,14,3
:P→L
:F→P
:randInt(1,S→F
:While F=P
:randInt(1,S→F
:End
:If L=T
:6→T
:If F+P=7
:Then
:5→S
:Else
:6→S
:End
:Output(A,B,sub(Str0,F,1)+sub(Str0,randInt(7,9),1
:End
:End
 
Last edited:
Some improvements ...
179 characters.

Code:
function r(n){if(n)return Math.floor(Math.random()*n);for(d=b=j=c=a=4;j++<29;){for(;a==c&&d&b;b=r(2)+1,a=r(3));d=a!=c?b:d+b;c=a;document.write(" RLFBUD"[a*2+b]+" 2'"[r(3)]+" ")}}

just call r() with no args.

I've changed the structure but gained only 3 characters more:
176 characters:
Code:
function r(n){if(n)return Math.floor(Math.random()*n);for(d=b=j=c=a=4;j<29;)b=r(2)+1,a=r(3),a==c&&d&b||(d=a!=c?b:d+b,c=a,j++,document.write(" RLFBUD"[a*2+b]+" 2'"[r(3)]+" "))}

there are some long names in javascript that can't be avoided such as:
function(){} return Math.floor() Math.random() document.write()
and they account for 64 characters.
 
Back
Top