mirror of
https://github.com/Baipyrus/AoC-23.git
synced 2024-12-27 04:21:45 +00:00
douplicate rows
This commit is contained in:
parent
a8c4e3f737
commit
49cbce92e9
@ -1,8 +1,22 @@
|
|||||||
import { readFileSync } from "fs";
|
import { readFileSync } from "fs";
|
||||||
const t0 = performance.now();
|
const t0 = performance.now();
|
||||||
|
|
||||||
const input = readFileSync("input.txt").toString();
|
const input = readFileSync("input.txt")
|
||||||
console.log(input);
|
.toString()
|
||||||
|
.split(/\r*\n/)
|
||||||
|
.filter((e) => e.length > 0)
|
||||||
|
.map((e) => e.split(""));
|
||||||
|
|
||||||
|
const expand = (arr) =>
|
||||||
|
arr.reduce(
|
||||||
|
(a, i) => [
|
||||||
|
...a,
|
||||||
|
...(i.some((e) => e !== ".") ? [i] : [i, Array(i.length).fill(".")]),
|
||||||
|
],
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(expand(input));
|
||||||
|
|
||||||
const t1 = performance.now();
|
const t1 = performance.now();
|
||||||
console.log(`Runtime: ${t1 - t0}ms`);
|
console.log(`Runtime: ${t1 - t0}ms`);
|
||||||
|
Loading…
Reference in New Issue
Block a user