I have left the arrLot array alone for now. But this is my guess at what your code needs to be.
Basically I convert arrIns array to one big string, then compare sub-strings with i. If the value of i isn't found then arr[ ] = i
function zeroAdjust(n) {
var t = "0"+n;
return t.substring(t.length-2,t.length);
}
var arrIns = [ "01","21","24","28","42","48",
"12","23","34","36","37","46",
"03","18","19","25","44","45" ];
var allLucky = arrIns.toString();
var arrLot = [];
var arr = [];
var count = 0;
var t;
for(var i=1; i<50; i++)
{
if (allLucky.indexOf(zeroAdjust(i)) == -1 ) {
arr[count] = i;
count++;
}
}
document.write("length of arr[] ="+ count +"<br>");
I have provided this just to help you move forward (if my guess was correct)
here are some more bits of code for you to look at.
csv = comma,separated,values which is what you get with an array.toString() call.
var arrIns = [ "01","21","24","28","42","48",
"12","23","34","36","37","46",
"03","18","19","25","44","45" ];
var arr_to_csv = arrIns.toString();
document.write(arr_to_csv);
var arr_from_csv = [];
var tmp = arr_to_csv.split(",");
for (var i=0; i < tmp.length; i++) {
arr_from_csv[i] = parseInt( tmp[i]);
document.write(arr_from_csv[i]);
}
The following code has arrIns as a N-dimensional array (3x6) of numbers, but it would complicate the code for comparisons, like the allLucky string compare above.
var arrIns = [ [ 1,21,24,28,42,48],
[12,23,34,36,37,46],
[ 3,18,19,25,44,45]
];
document.write("lucky numbers, one week at a time<br>");
for (var week=1; week < 4; week++) {
document.write("week no: "+ week +"<br>");
for (var i=0; i < 6; i++) {
document.write(arrIns[week-1][i]);
}
}
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
modified 16-Apr-13 17:35pm.
|