From de2b777f3759fbc766145c7eaa867ee5fce47292 Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Mon, 11 Dec 2023 10:56:20 +0100 Subject: [PATCH] split all types of linebreak --- Day01/Part1.js | 2 +- Day01/Part2.js | 2 +- Day02/Part1.js | 2 +- Day02/Part2.js | 2 +- Day03/Part1.js | 2 +- Day04/Part1.js | 2 +- Day04/Part2.js | 2 +- Day05/Part1.js | 2 +- Day06/Part1.js | 2 +- Day06/Part2.js | 2 +- Day07/Part1.js | 2 +- Day07/Part2.js | 2 +- Day08/Part1.js | 2 +- Day08/Part2.js | 2 +- Day09/Part1.js | 2 +- Day09/Part2.js | 2 +- Day10/Part1.js | 2 +- Day10/Part2.js | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Day01/Part1.js b/Day01/Part1.js index 311037f..4903ed6 100644 --- a/Day01/Part1.js +++ b/Day01/Part1.js @@ -3,7 +3,7 @@ const t0 = performance.now(); const lines = readFileSync("input.txt") .toString() - .split("\n") + .split(/\r*\n/) .filter((e) => e.length > 0); const numbers = lines.map((a) => a diff --git a/Day01/Part2.js b/Day01/Part2.js index 9ae0268..5c08bbd 100644 --- a/Day01/Part2.js +++ b/Day01/Part2.js @@ -15,7 +15,7 @@ const names = { }; const lines = readFileSync("input.txt") .toString() - .split("\n") + .split(/\r*\n/) .filter((e) => e.length > 0); const numbers = lines.map((a) => { const f1 = Object.keys(names) diff --git a/Day02/Part1.js b/Day02/Part1.js index 456972d..921818f 100644 --- a/Day02/Part1.js +++ b/Day02/Part1.js @@ -3,7 +3,7 @@ const t0 = performance.now(); const lines = readFileSync("input.txt") .toString() - .split("\n") + .split(/\r*\n/) .filter((e) => e.length > 0); const ids = lines.map((e) => { const current = parseInt(e.match(/^Game (\d{1,3}):/)[1]); diff --git a/Day02/Part2.js b/Day02/Part2.js index 564c3db..c3559fb 100644 --- a/Day02/Part2.js +++ b/Day02/Part2.js @@ -3,7 +3,7 @@ const t0 = performance.now(); const lines = readFileSync("input.txt") .toString() - .split("\n") + .split(/\r*\n/) .filter((e) => e.length > 0); const powers = lines.map((e) => { const pulls = e.split(":")[1].trim().split(";"); diff --git a/Day03/Part1.js b/Day03/Part1.js index 1309c7c..af7f56d 100644 --- a/Day03/Part1.js +++ b/Day03/Part1.js @@ -3,7 +3,7 @@ const t0 = performance.now(); const lines = readFileSync("input.txt") .toString() - .split("\n") + .split(/\r*\n/) .filter((e) => e.length > 0) .map((e) => e.split("")); const numbers = lines.map((a) => { diff --git a/Day04/Part1.js b/Day04/Part1.js index ff27adc..ddbdeb8 100644 --- a/Day04/Part1.js +++ b/Day04/Part1.js @@ -3,7 +3,7 @@ const t0 = performance.now(); const lines = readFileSync("input.txt") .toString() - .split("\n") + .split(/\r*\n/) .filter((e) => e.length > 0); const cards = lines.map((line) => { const id = parseInt(line.match(/^Card\s{1,}(\d{1,3}):/)[1]); diff --git a/Day04/Part2.js b/Day04/Part2.js index fb1e4d0..025bfa6 100644 --- a/Day04/Part2.js +++ b/Day04/Part2.js @@ -3,7 +3,7 @@ const t0 = performance.now(); const lines = readFileSync("input.txt") .toString() - .split("\n") + .split(/\r*\n/) .filter((e) => e.length > 0); const cards = lines.map((line) => { const id = parseInt(line.match(/^Card\s{1,}(\d{1,3}):/)[1]); diff --git a/Day05/Part1.js b/Day05/Part1.js index aad52a0..306f529 100644 --- a/Day05/Part1.js +++ b/Day05/Part1.js @@ -10,7 +10,7 @@ const seeds = categories[0] .slice(1) .map((e) => parseInt(e)); const dictionaries = categories.slice(1).map((e) => { - const splits = e.split("\n").filter((e) => e.length > 0); + const splits = e.split(/\r*\n/).filter((e) => e.length > 0); const name = splits[0].replace(" map:", ""); const maps = splits.slice(1).map((a) => a diff --git a/Day06/Part1.js b/Day06/Part1.js index 3ae0918..6008238 100644 --- a/Day06/Part1.js +++ b/Day06/Part1.js @@ -1,7 +1,7 @@ import { readFileSync } from "fs"; const t0 = performance.now(); -const input = readFileSync("input.txt").toString().split("\n"); +const input = readFileSync("input.txt").toString().split(/\r*\n/); const time = input[0] .split(/\s{1,}/) .slice(1) diff --git a/Day06/Part2.js b/Day06/Part2.js index 0060d1b..3b5ec91 100644 --- a/Day06/Part2.js +++ b/Day06/Part2.js @@ -1,7 +1,7 @@ import { readFileSync } from "fs"; const t0 = performance.now(); -const input = readFileSync("input.txt").toString().split("\n"); +const input = readFileSync("input.txt").toString().split(/\r*\n/); const time = parseInt( input[0] .split(/\s{1,}/) diff --git a/Day07/Part1.js b/Day07/Part1.js index f4717f8..27d1e0f 100644 --- a/Day07/Part1.js +++ b/Day07/Part1.js @@ -13,7 +13,7 @@ const cardPattern = [ const cards = ["A", "K", "Q", "J", "T", "9", "8", "7", "6", "5", "4", "3", "2"]; const input = readFileSync("input.txt") .toString() - .split("\n") + .split(/\r*\n/) .filter((e) => e.length > 0); const plays = input .map((p) => { diff --git a/Day07/Part2.js b/Day07/Part2.js index 7167186..93ecabe 100644 --- a/Day07/Part2.js +++ b/Day07/Part2.js @@ -14,7 +14,7 @@ const cards = ["A", "K", "Q", "T", "9", "8", "7", "6", "5", "4", "3", "2", "J"]; const JOKER_INDEX = "12"; const input = readFileSync("input.txt") .toString() - .split("\n") + .split(/\r*\n/) .filter((e) => e.length > 0); const plays = input .map((p) => { diff --git a/Day08/Part1.js b/Day08/Part1.js index de19b03..52df938 100644 --- a/Day08/Part1.js +++ b/Day08/Part1.js @@ -3,7 +3,7 @@ const t0 = performance.now(); const input = readFileSync("input.txt") .toString() - .split("\n") + .split(/\r*\n/) .filter((e) => e.length > 0); const instructions = input[0].split(""); const maps = input.slice(1).map((a) => { diff --git a/Day08/Part2.js b/Day08/Part2.js index e9b6abf..d113699 100644 --- a/Day08/Part2.js +++ b/Day08/Part2.js @@ -3,7 +3,7 @@ const t0 = performance.now(); const input = readFileSync("input.txt") .toString() - .split("\n") + .split(/\r*\n/) .filter((e) => e.length > 0); const instructions = input[0].split(""); const maps = input.slice(1).map((a) => { diff --git a/Day09/Part1.js b/Day09/Part1.js index d6d403e..31c8f7b 100644 --- a/Day09/Part1.js +++ b/Day09/Part1.js @@ -3,7 +3,7 @@ const t0 = performance.now(); const input = readFileSync("input.txt") .toString() - .split("\n") + .split(/\r*\n/) .filter((e) => e.length > 0); const histories = input.map((e) => e.split(" ").map(Number)); const predictions = histories.map((e) => { diff --git a/Day09/Part2.js b/Day09/Part2.js index 91ad674..83a4b3d 100644 --- a/Day09/Part2.js +++ b/Day09/Part2.js @@ -3,7 +3,7 @@ const t0 = performance.now(); const input = readFileSync("input.txt") .toString() - .split("\n") + .split(/\r*\n/) .filter((e) => e.length > 0); const histories = input.map((e) => e.split(" ").map(Number)); const predictions = histories.map((e) => { diff --git a/Day10/Part1.js b/Day10/Part1.js index 91446da..5c2c35d 100644 --- a/Day10/Part1.js +++ b/Day10/Part1.js @@ -38,7 +38,7 @@ const compare = (a, b) => a.x === b.x && a.y === b.y; const input = readFileSync("input.txt") .toString() - .split("\n") + .split(/\r*\n/) .filter((e) => e.length > 0) .map((e) => e.split("")); const startY = input.findIndex((e) => e.includes("S")); diff --git a/Day10/Part2.js b/Day10/Part2.js index 8a1c74f..efbbabd 100644 --- a/Day10/Part2.js +++ b/Day10/Part2.js @@ -38,7 +38,7 @@ const compare = (a, b) => a.x === b.x && a.y === b.y; const input = readFileSync("input.txt") .toString() - .split("\n") + .split(/\r*\n/) .filter((e) => e.length > 0) .map((e) => e.split("")); const startY = input.findIndex((e) => e.includes("S"));