Created
February 6, 2012 11:35
-
-
Save deletosh/1751649 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var array1 = [0,8,1,0,0,0,8,6,7,8,9,5,2,6,3,0,7,4,1,1,0,0,7,0,0,8,6,7,8,9,5,9,1,1,3,0]; | |
var array2 = [1,0,0,0,8,6,7,8,9,1,3,0,0,8,5,2,6,3,0,7,4,1,1,0,0,7,0,0,8,6,7,8,9,5,9,1]; | |
var array3 = [1,0,5,2,6,3,0,7,4,1,1,0,0,7,0,0,8,6,7,8,9,5,0,0,8,6,7,8,9,1,3,0,0,8,9,1]; | |
function findPattern(array, array1, array2){ | |
var result=0; | |
for(i=0; i<array.length; i++){ | |
if( array[i] == 1 && | |
array[i+1] == 3 && | |
array[i+2] === 0 && | |
array[i+3] === 0 && | |
array[i+4] == 8|| | |
array1[i] == 1 && | |
array1[i+1] == 3 && | |
array1[i+2] === 0 && | |
array1[i+3] === 0 && | |
array1[i+4] == 8|| | |
array2[i] == 1 && | |
array2[i+1] == 3 && | |
array2[i+2] === 0 && | |
array2[i+3] === 0 && | |
array2[i+4] == 8){ | |
result += 1; | |
} | |
} | |
return result; | |
} | |
alert(findPattern(array3, array2, array1) + " Pattern found!"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment