This commit is contained in:
Rowan 2024-12-14 15:17:47 -06:00
parent 2758ef369d
commit 72b3ecfcbe

View file

@ -1,6 +1,3 @@
import { readFile } from 'node:fs/promises'
import { resolve } from 'node:path'
const pipe = (...fns) => x => fns.reduce((val, fn) => fn(val), x) const pipe = (...fns) => x => fns.reduce((val, fn) => fn(val), x)
const add = (a, b) => a + b const add = (a, b) => a + b
const mul = (a, b) => a * b const mul = (a, b) => a * b
@ -125,24 +122,3 @@ const checksum2 = blocks => {
const part1 = pipe(expand, enfrag, checksum) const part1 = pipe(expand, enfrag, checksum)
const part3 = pipe(expand3, defrag2, checksum2) const part3 = pipe(expand3, defrag2, checksum2)
//const tests = [
// ['1313165', 169],
// ['12345', 132],
// ['54321', 31],
// ['2333133121414131402', 2858],
// ['1010101010101010101010', 385],
// ['111111111111111111111', 290],
// ['10101010101010101010101', 506],
// ['90909', 513]
//]
//
//tests.forEach(([input, expected], i) => {
// //console.log(`input length is ${input.length}`)
// const result = part3(input)
// console.log(i, result === expected, result)
//})
readFile(resolve('./input'), { encoding: 'utf8' })
.then(part3)
.then(console.log)