mirror of
https://github.com/Baipyrus/AoC-23.git
synced 2024-11-14 09:43:49 +00:00
split all types of linebreak
This commit is contained in:
parent
7ded3bc3e6
commit
de2b777f37
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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]);
|
||||
|
@ -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(";");
|
||||
|
@ -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) => {
|
||||
|
@ -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]);
|
||||
|
@ -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]);
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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,}/)
|
||||
|
@ -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) => {
|
||||
|
@ -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) => {
|
||||
|
@ -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) => {
|
||||
|
@ -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) => {
|
||||
|
@ -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) => {
|
||||
|
@ -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) => {
|
||||
|
@ -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"));
|
||||
|
@ -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"));
|
||||
|
Loading…
Reference in New Issue
Block a user