I need to find an algorithm to allocate efficiently the coordinates of horizonatal/vertical sudoku line. Note that the grid is 3x3 and I have a 2nd array with 9 elements.

In order to get the actual values for the horizontal and vertical line i need to split this array, in different ways, there are patterns that i can split, and i would like to put this patterns in an algorithm rather than doing it manually. First array from the inner element of outer array, is a single box in the sudoku board. Pictorially would look like this.

[0][1][2]
[3][4][5]
[6][7][8]


var array = [[1,2,3,4,5,6,7,8,9],[...],[..],[..],[..],[..],[...],[..],[..]]

var first_horizontal_line = array[0].slice(0, 3).concat(array[1].slice(0, 
3)).concat(array[2].slice(0, 3));

var first_vertical_line = array[0][0].concat(array[0][3]).concat(array[0] 
[6]).concat(array[3][0].concat(array[3][3]).concat(array[3] 
[6])).concat(array[6][0].concat(array[6][3]).concat(array[6] 
[6])).split('');

0 Answers