-
Notifications
You must be signed in to change notification settings - Fork 2
/
boardprinter.js
55 lines (45 loc) · 1.37 KB
/
boardprinter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function boardDivide() {
console.log('+-------------+-------------+-------------+');
}
var divider = '| ';
var fullArrayLength = '*';
function line(sliceStart, sliceEnd, boardArray) {
var linePrint = '| ';
var boxPrint = function(boxSliceStart, boxSliceEnd) {
boardArray.slice(boxSliceStart,boxSliceEnd).forEach(function(number){
//fullArrayLength = fullArray[row][col].possibles.length;
//conditionally print number or other value if null
if (number > 0 ){
linePrint += (' ' + number + ' ')
}
else if (number<1){
linePrint += ('['+ number + ']')
}
})
linePrint += divider;
}
boxPrint(sliceStart, sliceEnd);
boxPrint(sliceStart+3, sliceEnd+3);
boxPrint(sliceStart+6, sliceEnd+6);
console.log(linePrint);
}
function boardPrinter(boardArray) {
var box1 = [0,9,18]
var box2 = [27,36,45]
var box3 = [54,63,72]
boardDivide();
box1.forEach(function(value, index){
line(box1[index], box1[index]+3, boardArray);
})
boardDivide();
box2.forEach(function(value, index){
line(box2[index], box2[index]+3, boardArray);
})
boardDivide();
box3.forEach(function(value, index){
line(box3[index], box3[index]+3, boardArray);
})
boardDivide();
};
//' 94 3 61 8 4 8 4 1 3 264 54 687 92 761 4 5 7 3 8 6 54 7 96 '
module.exports = boardPrinter;