var array = Array(); var i,j; for(i=1; I Write(newarr); function shuffle(array) { //v1.0 for(va..." />
Not my algorithm though script type="text/javascript"> var array = Array(); var i,j; for(i=1; I Write(newarr); function shuffle(array) { //v1.0 for(var j, x, I = array. Length; i; j = parseInt(Math.random() * i), x = array--i, arrayi = arrayj, arrayj = x); return array; }.
Thank you thank you thank you! Worked like a charm! – Leticia Meyer Mar 1 at 5:46 @Leticia Meyer you are welcome – Santosh Linkha Mar 1 at 5:46.
You should generate an array of all of the possible coordinate pairs, use a shuffling algorithm to put them into a random order, then print them out.
– Leticia Meyer Mar 1 at 5:12 Look at stackoverflow.Com/questions/962802/… for the shuffle. I don't know JavaScript well enough to write the code to create the array. – Jeremiah Willcock Mar 1 at 5:14 Ok... Wish I knew how to create the array.
Thanks for your help though, Jeremiah! – Leticia Meyer Mar 1 at 5:16 this is an elegant solution. – DhruvPathak Mar 1 at 5:31.
Here's one way: var answer = (function(width,height) { var result = ; for (var I = 1; I Length; k.
Array.prototype. Shuffle= function(force){ var i, temp, L= this. Length, A= force?
This: this.concat(); while(--L){ i= Math. Floor(Math.random()*L); temp= Ai; Ai= AL; AL= temp; } return A; } The purpose of the (optional) parameter is to shuffle the array itself. By default the array is not shuffled, but a shuffled copy is returned.
This should work: // New Array a = ; // 3 rows, 3 columns c = 3; r = 3; // fill array with every unique possibility for( var I = 1; I Length = a. Splice(Math. Floor(Math.random()*a.
Length), 1)0; } If you just want to print the results instead of having them in an array just do print instead of "resultresult. Length".
I have two variables set, a number of columns and a number of rows. I only want each pair to appear once, and it can't have 0s in it. All in a random order.
How would I do this?
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.