Number Scrambler?

Joined
Nov 14, 2007
Messages
144
Location
Pennsylvania
WCA ID
2008LIVE01
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 :)
 
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 :p.
 
(Johannes, any tips ;)?)
Code:
perl -mList::Util=shuffle -le 'print join v32, shuffle 1..12'
Code:
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.
 
Last edited:
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?
 

Attachments

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

First in my naievity, I did
Code:
(?~/: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
Code:
>:?~12
 
Last edited:
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 :)
 
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 :rolleyes: 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
 
Last edited:
Back
Top