-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpart_2.js
More file actions
25 lines (19 loc) · 791 Bytes
/
part_2.js
File metadata and controls
25 lines (19 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import fs from "node:fs";
import path from "node:path";
import { performance } from "node:perf_hooks";
import { fileURLToPath } from "url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
// ========================= //
// = Copyright (c) NullDev = //
// ========================= //
const INPUT = String(fs.readFileSync(path.join(__dirname, "input.txt"))).trim().split("-").map(Number);
const pStart = performance.now();
const RES = (new Array(INPUT[1] - INPUT[0]))
.fill(0)
.map((_, i) => i + INPUT[0])
.map(String)
.filter(p => !((p.match(/(\d)\1+/g) || []).filter((v)=>v.length === 2).length === 0 || p.split("").sort().join("") !== p))
.length;
const pEnd = performance.now();
console.log("PASSWORD COUNT: " + RES);
console.log(pEnd - pStart);