split all types of linebreak

This commit is contained in:
Baipyrus 2023-12-11 10:56:20 +01:00
parent 7ded3bc3e6
commit de2b777f37
18 changed files with 18 additions and 18 deletions

View File

@ -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

View File

@ -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)

View File

@ -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]);

View File

@ -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(";");

View File

@ -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) => {

View File

@ -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]);

View File

@ -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]);

View File

@ -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

View File

@ -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)

View File

@ -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,}/)

View File

@ -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) => {

View File

@ -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) => {

View File

@ -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) => {

View File

@ -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) => {

View File

@ -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) => {

View File

@ -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) => {

View File

@ -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"));

View File

@ -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"));