mirror of
https://github.com/Baipyrus/AoC-23.git
synced 2024-12-26 03:51:45 +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")
|
const lines = readFileSync("input.txt")
|
||||||
.toString()
|
.toString()
|
||||||
.split("\n")
|
.split(/\r*\n/)
|
||||||
.filter((e) => e.length > 0);
|
.filter((e) => e.length > 0);
|
||||||
const numbers = lines.map((a) =>
|
const numbers = lines.map((a) =>
|
||||||
a
|
a
|
||||||
|
@ -15,7 +15,7 @@ const names = {
|
|||||||
};
|
};
|
||||||
const lines = readFileSync("input.txt")
|
const lines = readFileSync("input.txt")
|
||||||
.toString()
|
.toString()
|
||||||
.split("\n")
|
.split(/\r*\n/)
|
||||||
.filter((e) => e.length > 0);
|
.filter((e) => e.length > 0);
|
||||||
const numbers = lines.map((a) => {
|
const numbers = lines.map((a) => {
|
||||||
const f1 = Object.keys(names)
|
const f1 = Object.keys(names)
|
||||||
|
@ -3,7 +3,7 @@ const t0 = performance.now();
|
|||||||
|
|
||||||
const lines = readFileSync("input.txt")
|
const lines = readFileSync("input.txt")
|
||||||
.toString()
|
.toString()
|
||||||
.split("\n")
|
.split(/\r*\n/)
|
||||||
.filter((e) => e.length > 0);
|
.filter((e) => e.length > 0);
|
||||||
const ids = lines.map((e) => {
|
const ids = lines.map((e) => {
|
||||||
const current = parseInt(e.match(/^Game (\d{1,3}):/)[1]);
|
const current = parseInt(e.match(/^Game (\d{1,3}):/)[1]);
|
||||||
|
@ -3,7 +3,7 @@ const t0 = performance.now();
|
|||||||
|
|
||||||
const lines = readFileSync("input.txt")
|
const lines = readFileSync("input.txt")
|
||||||
.toString()
|
.toString()
|
||||||
.split("\n")
|
.split(/\r*\n/)
|
||||||
.filter((e) => e.length > 0);
|
.filter((e) => e.length > 0);
|
||||||
const powers = lines.map((e) => {
|
const powers = lines.map((e) => {
|
||||||
const pulls = e.split(":")[1].trim().split(";");
|
const pulls = e.split(":")[1].trim().split(";");
|
||||||
|
@ -3,7 +3,7 @@ const t0 = performance.now();
|
|||||||
|
|
||||||
const lines = readFileSync("input.txt")
|
const lines = readFileSync("input.txt")
|
||||||
.toString()
|
.toString()
|
||||||
.split("\n")
|
.split(/\r*\n/)
|
||||||
.filter((e) => e.length > 0)
|
.filter((e) => e.length > 0)
|
||||||
.map((e) => e.split(""));
|
.map((e) => e.split(""));
|
||||||
const numbers = lines.map((a) => {
|
const numbers = lines.map((a) => {
|
||||||
|
@ -3,7 +3,7 @@ const t0 = performance.now();
|
|||||||
|
|
||||||
const lines = readFileSync("input.txt")
|
const lines = readFileSync("input.txt")
|
||||||
.toString()
|
.toString()
|
||||||
.split("\n")
|
.split(/\r*\n/)
|
||||||
.filter((e) => e.length > 0);
|
.filter((e) => e.length > 0);
|
||||||
const cards = lines.map((line) => {
|
const cards = lines.map((line) => {
|
||||||
const id = parseInt(line.match(/^Card\s{1,}(\d{1,3}):/)[1]);
|
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")
|
const lines = readFileSync("input.txt")
|
||||||
.toString()
|
.toString()
|
||||||
.split("\n")
|
.split(/\r*\n/)
|
||||||
.filter((e) => e.length > 0);
|
.filter((e) => e.length > 0);
|
||||||
const cards = lines.map((line) => {
|
const cards = lines.map((line) => {
|
||||||
const id = parseInt(line.match(/^Card\s{1,}(\d{1,3}):/)[1]);
|
const id = parseInt(line.match(/^Card\s{1,}(\d{1,3}):/)[1]);
|
||||||
|
@ -10,7 +10,7 @@ const seeds = categories[0]
|
|||||||
.slice(1)
|
.slice(1)
|
||||||
.map((e) => parseInt(e));
|
.map((e) => parseInt(e));
|
||||||
const dictionaries = categories.slice(1).map((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 name = splits[0].replace(" map:", "");
|
||||||
const maps = splits.slice(1).map((a) =>
|
const maps = splits.slice(1).map((a) =>
|
||||||
a
|
a
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { readFileSync } from "fs";
|
import { readFileSync } from "fs";
|
||||||
const t0 = performance.now();
|
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]
|
const time = input[0]
|
||||||
.split(/\s{1,}/)
|
.split(/\s{1,}/)
|
||||||
.slice(1)
|
.slice(1)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { readFileSync } from "fs";
|
import { readFileSync } from "fs";
|
||||||
const t0 = performance.now();
|
const t0 = performance.now();
|
||||||
|
|
||||||
const input = readFileSync("input.txt").toString().split("\n");
|
const input = readFileSync("input.txt").toString().split(/\r*\n/);
|
||||||
const time = parseInt(
|
const time = parseInt(
|
||||||
input[0]
|
input[0]
|
||||||
.split(/\s{1,}/)
|
.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 cards = ["A", "K", "Q", "J", "T", "9", "8", "7", "6", "5", "4", "3", "2"];
|
||||||
const input = readFileSync("input.txt")
|
const input = readFileSync("input.txt")
|
||||||
.toString()
|
.toString()
|
||||||
.split("\n")
|
.split(/\r*\n/)
|
||||||
.filter((e) => e.length > 0);
|
.filter((e) => e.length > 0);
|
||||||
const plays = input
|
const plays = input
|
||||||
.map((p) => {
|
.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 JOKER_INDEX = "12";
|
||||||
const input = readFileSync("input.txt")
|
const input = readFileSync("input.txt")
|
||||||
.toString()
|
.toString()
|
||||||
.split("\n")
|
.split(/\r*\n/)
|
||||||
.filter((e) => e.length > 0);
|
.filter((e) => e.length > 0);
|
||||||
const plays = input
|
const plays = input
|
||||||
.map((p) => {
|
.map((p) => {
|
||||||
|
@ -3,7 +3,7 @@ const t0 = performance.now();
|
|||||||
|
|
||||||
const input = readFileSync("input.txt")
|
const input = readFileSync("input.txt")
|
||||||
.toString()
|
.toString()
|
||||||
.split("\n")
|
.split(/\r*\n/)
|
||||||
.filter((e) => e.length > 0);
|
.filter((e) => e.length > 0);
|
||||||
const instructions = input[0].split("");
|
const instructions = input[0].split("");
|
||||||
const maps = input.slice(1).map((a) => {
|
const maps = input.slice(1).map((a) => {
|
||||||
|
@ -3,7 +3,7 @@ const t0 = performance.now();
|
|||||||
|
|
||||||
const input = readFileSync("input.txt")
|
const input = readFileSync("input.txt")
|
||||||
.toString()
|
.toString()
|
||||||
.split("\n")
|
.split(/\r*\n/)
|
||||||
.filter((e) => e.length > 0);
|
.filter((e) => e.length > 0);
|
||||||
const instructions = input[0].split("");
|
const instructions = input[0].split("");
|
||||||
const maps = input.slice(1).map((a) => {
|
const maps = input.slice(1).map((a) => {
|
||||||
|
@ -3,7 +3,7 @@ const t0 = performance.now();
|
|||||||
|
|
||||||
const input = readFileSync("input.txt")
|
const input = readFileSync("input.txt")
|
||||||
.toString()
|
.toString()
|
||||||
.split("\n")
|
.split(/\r*\n/)
|
||||||
.filter((e) => e.length > 0);
|
.filter((e) => e.length > 0);
|
||||||
const histories = input.map((e) => e.split(" ").map(Number));
|
const histories = input.map((e) => e.split(" ").map(Number));
|
||||||
const predictions = histories.map((e) => {
|
const predictions = histories.map((e) => {
|
||||||
|
@ -3,7 +3,7 @@ const t0 = performance.now();
|
|||||||
|
|
||||||
const input = readFileSync("input.txt")
|
const input = readFileSync("input.txt")
|
||||||
.toString()
|
.toString()
|
||||||
.split("\n")
|
.split(/\r*\n/)
|
||||||
.filter((e) => e.length > 0);
|
.filter((e) => e.length > 0);
|
||||||
const histories = input.map((e) => e.split(" ").map(Number));
|
const histories = input.map((e) => e.split(" ").map(Number));
|
||||||
const predictions = histories.map((e) => {
|
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")
|
const input = readFileSync("input.txt")
|
||||||
.toString()
|
.toString()
|
||||||
.split("\n")
|
.split(/\r*\n/)
|
||||||
.filter((e) => e.length > 0)
|
.filter((e) => e.length > 0)
|
||||||
.map((e) => e.split(""));
|
.map((e) => e.split(""));
|
||||||
const startY = input.findIndex((e) => e.includes("S"));
|
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")
|
const input = readFileSync("input.txt")
|
||||||
.toString()
|
.toString()
|
||||||
.split("\n")
|
.split(/\r*\n/)
|
||||||
.filter((e) => e.length > 0)
|
.filter((e) => e.length > 0)
|
||||||
.map((e) => e.split(""));
|
.map((e) => e.split(""));
|
||||||
const startY = input.findIndex((e) => e.includes("S"));
|
const startY = input.findIndex((e) => e.includes("S"));
|
||||||
|
Loading…
Reference in New Issue
Block a user