wip5
This commit is contained in:
parent
e1ca53ecb0
commit
4294e398ea
2 changed files with 24 additions and 15 deletions
24
4/index.js
24
4/index.js
|
|
@ -24,7 +24,7 @@ for (row of inputArr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("lineRegex: ",lineRegex)
|
console.log("lineRegex: ", lineRegex);
|
||||||
|
|
||||||
// console.log(inputArr)
|
// console.log(inputArr)
|
||||||
const maxRows = inputArr.length;
|
const maxRows = inputArr.length;
|
||||||
|
|
@ -35,43 +35,43 @@ for (let x = 0; x < maxRows; x++) {
|
||||||
for (let y = 0; y + 3 < maxLetters; y++) {
|
for (let y = 0; y + 3 < maxLetters; y++) {
|
||||||
const word = inputArr[x][y] + inputArr[x][y + 1] + inputArr[x][y + 2] + inputArr[x][y + 3];
|
const word = inputArr[x][y] + inputArr[x][y + 1] + inputArr[x][y + 2] + inputArr[x][y + 3];
|
||||||
// console.log(word)
|
// console.log(word)
|
||||||
if (word.match(forwardRegex)|| word.match(backwardRegex)) {
|
if (word.match(forwardRegex) || word.match(backwardRegex)) {
|
||||||
totalMatches++;
|
totalMatches++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("after horizontal: ",totalMatches)
|
console.log("after horizontal: ", totalMatches);
|
||||||
|
|
||||||
//vertical words
|
//vertical words
|
||||||
for (let x = 0; x + 3 < maxRows; x++) {
|
for (let x = 0; x + 3 < maxRows; x++) {
|
||||||
for (let y = 0; y < maxLetters; y++) {
|
for (let y = 0; y < maxLetters; y++) {
|
||||||
const word = inputArr[x][y] + inputArr[x + 1][y] + inputArr[x + 2][y] + inputArr[x + 3][y];
|
const word = inputArr[x][y] + inputArr[x + 1][y] + inputArr[x + 2][y] + inputArr[x + 3][y];
|
||||||
if (word.match(forwardRegex)|| word.match(backwardRegex)) {
|
if (word.match(forwardRegex) || word.match(backwardRegex)) {
|
||||||
totalMatches++;
|
totalMatches++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("after vertical: ",totalMatches)
|
console.log("after vertical: ", totalMatches);
|
||||||
//angled words nw-se
|
//angled words nw-se
|
||||||
for (let x = 0; x + 3 < maxRows; x++) {
|
for (let x = 0; x + 3 < maxRows; x++) {
|
||||||
for (let y = 0; y +3< maxLetters; y++) {
|
for (let y = 0; y + 3 < maxLetters; y++) {
|
||||||
const word = inputArr[x][y] + inputArr[x + 1][y + 1] + inputArr[x + 2][y + 2] + inputArr[x + 3][y + 3];
|
const word = inputArr[x][y] + inputArr[x + 1][y + 1] + inputArr[x + 2][y + 2] + inputArr[x + 3][y + 3];
|
||||||
if (word.match(forwardRegex)|| word.match(backwardRegex)) {
|
if (word.match(forwardRegex) || word.match(backwardRegex)) {
|
||||||
totalMatches++;
|
totalMatches++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("after nw-se: ",totalMatches)
|
console.log("after nw-se: ", totalMatches);
|
||||||
//angled words ne-sw
|
//angled words ne-sw
|
||||||
for (let x = 0; x + 3 < maxRows; x++) {
|
for (let x = 0; x + 3 < maxRows; x++) {
|
||||||
for (let y = 0; y +3< maxLetters; y++) {
|
for (let y = 0; y + 3 < maxLetters; y++) {
|
||||||
const word = inputArr[x][y+3] + inputArr[x+1][y + 2] + inputArr[x + 2][y + 1] + inputArr[x+3][y];
|
const word = inputArr[x][y + 3] + inputArr[x + 1][y + 2] + inputArr[x + 2][y + 1] + inputArr[x + 3][y];
|
||||||
if (word.match(forwardRegex)|| word.match(backwardRegex)) {
|
if (word.match(forwardRegex) || word.match(backwardRegex)) {
|
||||||
totalMatches++;
|
totalMatches++;
|
||||||
}
|
}
|
||||||
// console.log(word);
|
// console.log(word);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("after ne-sw: ",totalMatches)
|
console.log("after ne-sw: ", totalMatches);
|
||||||
|
|
||||||
console.log("totalMatches: ", totalMatches);
|
console.log("totalMatches: ", totalMatches);
|
||||||
|
|
|
||||||
15
5/index.js
15
5/index.js
|
|
@ -38,6 +38,15 @@ function loadTree() {
|
||||||
|
|
||||||
loadTree();
|
loadTree();
|
||||||
|
|
||||||
console.log(rulesMapForward);
|
// console.log(rulesMapForward);
|
||||||
console.log("------------------");
|
// console.log("------------------");
|
||||||
console.log(rulesMapBackward);
|
// console.log(rulesMapBackward);
|
||||||
|
|
||||||
|
const inputPagesArr =inputPages.split("\n")
|
||||||
|
|
||||||
|
for (book of inputPagesArr){
|
||||||
|
const pages = book.split(",")
|
||||||
|
for (let page =0;page<pages.length;page++){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue