PDA

HunterFai
11-23-2012, 09:33 AM
Let say i have many count as below

A1_S1 = 0
contiue to 100
A100_S100 = 0

which i want to count each of them got how much inside after the checker. Yes i do understand follow if/else or switch will help me done this, but can i know is there any faster way like "A1" and "S1" finder which is match will plus 1.

switch(Checker1){
case A1: A0 = A1++;break;
case A2: A0 = A2++;break;
}

switch(checker2){
case S1: S0 = S1++;break;
case S2: S0 = S2++;break;
}

var A0,S0;
var Total = A0 + S0;
if(Total == A1_S1){
A1_S1++;
}
else if(Total == A2_S1){
A2_S1++
}
else if(Total == A2_S2){
A2_S2++
}
else if(Total == A0_S1){
A0_S1++
}

devnull69
11-23-2012, 09:48 AM
Every time you start to add literal digits to your variable names you'll have to consider using Arrays instead. Because this is exactly why they have been introduced into programming languages :D

To initialize a two-dimensional array with zeroes you could do:

var myArray = [];
for(i=0; i<100; i++) {
myArray[i] = [];
for(j=0; j<100; j++) {
myArray[i][j] = 0;
}
}

Now you can access the content easily like

// even using variables
var myindex1 = 10;
var myindex2 = 70;

HunterFai
11-27-2012, 04:23 AM
Thank for your reply, first thing i wish to thank you for trying to help me out, and i have post this in few website also no one trying to help at all.

For my code, what i wish to do is permutation count.

like 1,2,3
1,2,3
1,2,3

output to
111 = 1
112 = 1
113 = 1
121 = 1
122 = 1
123 = 1
133 = 1
211 = 1
212 = 1
213 = 1
333 = 1
and continue till all number is count and also store to the array which can check how many count after all

code will check the input number and count how many outcome and show the results with how many outcome and each have how many after permutation count.

Its hard to do?.

Anyway thank you for help.

Philip M
11-27-2012, 07:36 AM
Thank for your reply, first thing i wish to thank you for trying to help me out, and i have post this in few website also no one trying to help at all.

For my code, what i wish to do is permutation count.

like 1,2,3
1,2,3
1,2,3

output to
111 = 1
112 = 1
113 = 1
121 = 1
122 = 1
123 = 1
133 = 1
211 = 1
212 = 1
213 = 1
333 = 1
and continue till all number is count and also store to the array which can check how many count after all

code will check the input number and count how many outcome and show the results with how many outcome and each have how many after permutation count.

Its hard to do?.

Anyway thank you for help.

http://scriptar.com/JavaScript/permute.html
http://jsfiddle.net/MgmMg/6/

The search feature of this forum is also your friend:-