sort 16 images

by Gerard <gdeboer(at)mediaport.org>

 Date:  Wed, 01 Mar 2000 13:36:15 +0100
 To:  hwg-techniques(at)hwg.org
  todo: View Thread, Original
Hello all,

Not being a mathematician of any kind I had to invent a script that would 
sort 16 images at random for a game of "memory".

I came up with this:

tc=""
teller = new Array()
teller[tc++] = ''
teller[tc++] = 'one'
teller[tc++] = 'two'
teller[tc++] = 'three'
teller[tc++] = 'four'
teller[tc++] = 'five'
teller[tc++] = 'six'
teller[tc++] = 'seven'
teller[tc++] = 'eight'
teller[tc++] = 'nine'
teller[tc++] = 'ten'
teller[tc++] = 'eleven'
teller[tc++] = 'twelve'
teller[tc++] = 'thirteen'
teller[tc++] = '14'
teller[tc++] = 'fifteen'
teller[tc++] = '16'



function calc(){

var now = new Date()
rand = (Math.round(now.getTime() / i) % 16)+1
if(i<17){
num = teller[rand]
if(i>0 && numb.indexOf(num)!=-1){setTimeout('calc()',10)}
else{
numb += num+"<br>"
i++
if(i<17){
calc()
}
}

, and it worked!! Check it out:

http://www.kw.nl/~gerard/memory/rand.html

But I think there must be a better way to sort 16 items. This takes too long...
If anybody has any suggestions...

Anyway, the game works:

http://www.kw.nl/~gerard/memory/mem1/index5.html

(a rough version)

Thanks in advance,

Gerard

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA