# Number Scrambler?



## Speedy McFastfast (Mar 2, 2008)

I've been working a lot on BLD lately, but I'm having a horrible time memorizing edges. I was wondering, is there a scrambler out there that can give me a random scramble of the numbers 1-12? This would really help me practice BLD solving, or at least the memorizing part of it. And best of all, I could do it while in school


----------



## ShadenSmith (Mar 2, 2008)

I can write a program to do that if you'd like.


----------



## watermelon (Mar 2, 2008)

Here's some perl that should do the trick:

print("Generate numbers up to: ");
chomp($bound = <STDIN>);
for$i(1..$bound){$a[$i-1]=$i;}
while(@a>0){$b[@b]=splice(@a,int(rand(@a)),1);}
print("@b");<>

(Johannes, any tips ?)

However, I doubt your school computers have perl installed, so I'll try to write a Java version later .


----------



## Johannes91 (Mar 2, 2008)

watermelon said:


> (Johannes, any tips ?)




```
perl -mList::Util=shuffle -le 'print join v32, shuffle 1..12'
```


```
javascript: Array.prototype.swap = function (x, y) { var temp = this[x]; this[x] = this[y]; this[y] = temp; return this }; Array.prototype.shuffle = function () { for (var i = 0; i < this.length; i++) { this.swap(i, Math.floor(Math.random() * (this.length - i) + i)) } return this }; alert([1,2,3,4,5,6,7,8,9,10,11,12].shuffle().join(" "))
```
I'd make it a link but this forum doesn't like it.


----------



## fw (Mar 2, 2008)

http://www.random.org/integers/


----------



## Johannes91 (Mar 2, 2008)

fw said:


> http://www.random.org/integers/


Google gives several like that, but I didn't find any that generate a random permutation.


----------



## jeff081692 (Mar 2, 2008)

http://www.random.org/sequences/

This one does not repeat numbers.


----------



## joey (Mar 2, 2008)

Do I win?

```
?~12
```
Yup


----------



## watermelon (Mar 2, 2008)

Meh, here's my lame Java program. Double click numbers.bat to run it (I was too lazy to make it into a *.jar, so this will probably only work on computers running Windows).

@joey: Which language is that, if one at all?


----------



## joey (Mar 2, 2008)

Oh sorry watermelon. That is J. Yes it does work, it gives random permutations!

First in my naievity, I did

```
(?~/:i.)12
```
, which first generates 0-11, then a random permutation, which it is sorted by. Then I thought, why do I need the list of 0-11, why not juse use the random permutation.

Mine actually gives the numbers 0-11, to make it give 1-12, the code is

```
>:?~12
```


----------



## watermelon (Mar 2, 2008)

Ah, I should have known . J is definitely one of the most concise languages I've encountered.


----------



## jeff081692 (Mar 2, 2008)

I like your program watermelon.


----------



## Speedy McFastfast (Mar 3, 2008)

Thanks guys! I should have thought of googling for stuff like this...

All of this should definitely help me get better with BLD memorizing. The only thing that the sequence thing doesn't do is insert random letters that I use to break into a new cycle


----------



## alexc (Mar 3, 2008)

I like that random sequence website, it is quite useful for anyone using numbers.


----------



## mrCage (Mar 3, 2008)

Hi 

Chect out this webpage. Then use *view source* or other tool to rip the sourcecode. You can now run it offline too. Ugly but fully working simple javascript  It uses an array initialised with values 1 .. 12. Then it does a number of random swaps to make random sequence and finally produces a string to put into a text area element on the page! 

- Per


----------



## dbeyer (Mar 5, 2008)

Oh Check this out

for all you letter pair people like me
http://www.lerfjhax.com/scrambler


----------

