diff options
author | Marvin Borner | 2022-12-06 06:38:27 +0100 |
---|---|---|
committer | Marvin Borner | 2022-12-06 06:38:27 +0100 |
commit | 5945f4e31ea287d6b7bfaebe9c504e8807a4510c (patch) | |
tree | 0b6e53904d4796c210b6231c40959e07cd926909 /2022/06 | |
parent | a59f60048ccf3f29aeccc8deff016acf8fdd300c (diff) |
js
Diffstat (limited to '2022/06')
-rw-r--r-- | 2022/06/solve.js | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/2022/06/solve.js b/2022/06/solve.js index fb5105a..c19e1da 100644 --- a/2022/06/solve.js +++ b/2022/06/solve.js @@ -1,19 +1,12 @@ -data = require("fs").readFileSync("input", "utf8").split("\n"); +d=require("fs").readFileSync("input", "utf8").split("") -function part1() +function solve(k) { - res = 0 - return res -} - -function part2() -{ - res = 0 - return res + return d.map((_,i)=>d.slice(i,i+k)).findIndex(a=>(new Set(a)).size==a.length)+k } const tic = performance.now(); -console.log(part1()); -console.log(part2()); +console.log(solve(4)); +console.log(solve(14)); const toc = performance.now(); console.log("TIME: " + ((toc - tic) / 1000).toFixed(6) + " seconds"); |