diff --git a/04/index.ts b/04/index.ts index fc91844..0cad557 100644 --- a/04/index.ts +++ b/04/index.ts @@ -17,16 +17,12 @@ console.log( .reduce( (coll, curr, index, array) => { // 2D string matching is a pain. Let's turn it into a 1D problem! - // create the columns curr.split("").forEach((s, i) => { + // create the columns coll[i] += s; - }); - // create the down-left-diagonals - curr.split("").forEach((s, i) => { - coll[i + array.length + index] += s; - }); - // create the down-right-diagonals - curr.split("").forEach((s, i) => { + // create the left-diagonals + coll[array.length + index + i] += s; + // create the right-diagonals coll[array.length * 4 + index - i - 2] += s; }); // include the original row