Here's a quick and dirty bash script if you have linux or unix somewhere:
- Code: Select all
#!/bin/bash
for row in `seq 1 10`; do #10 rows
for key in `seq 1 12`; do #12 keys per row
pos[0]=$((RANDOM%6+1)) #random bitting 1-6 in 1st position
echo -n ${pos[0]} #print bitting of 1st position
for i in `seq 1 4`; do #add 4 more bittings to this key
pos[$i]=$((RANDOM%6+1))
current=${pos[$i]} #current bitting
prev=${pos[$i-1]} #previous bitting
if [ "$current" = "$prev" ] #better randomization--if two
then pos[$i]=$((RANDOM%6+1)) #same bittings, this re-randomizes
fi #one of them.
if [ `expr "$prev" % 5` = "1" ] #matches both 1 and 6
then pos[$i]=$((RANDOM%4+2)) #(if prev is 1 or 6, this ensures
fi #next can only be 2 through 5).
echo -n ${pos[$i]} #print out remaining bittings
#for this key.
done #next i
echo -n " " #prints space between keys
done #next key
echo
done #next row
And here is some sample output:
legion@neutronstar:~$ ./bitting.sh
65462 56552 53143 42565 34631 25133 62435 46552 21456 51214 35356 44536
65145 65432 24131 63523 24346 35412 64363 65156 63521 52232 12415 45136
23512 41514 25434 24214 52642 15263 41262 62415 36546 14154 34134 54536
34154 35326 62146 25412 62621 25652 32532 62426 65123 64623 14634 45342
51563 36423 43414 41421 45454 12324 15254 14235 52536 26321 45145 63465
54565 13154 53546 62635 63143 42645 35134 26251 65341 56315 63242 56564
54565 52352 25152 54135 54125 13256 51563 53514 62313 65412 32134 53652
54521 65546 56351 15635 35464 21341 65451 42546 26431 42415 22142 33651
12152 43546 53241 51324 62364 23435 35362 46265 62364 36426 54214 15212
46523 25263 41315 53645 51341 53635 51214 54413 36252 21536 52363 13142
EDIT: cleaned up code a little and added a 10-row wrapper, so each run will give you 120 random keys. 1 and 6 will never appear next to each other, and duplicate position bittings (i.e., 11, 22, etc.) should be fairly rare.
-steve