This commit is contained in:
2024-12-02 14:28:09 +01:00
parent e6052f71c4
commit 22e0cea352
6 changed files with 1130 additions and 7 deletions

View File

@@ -1,7 +1,8 @@
import * as path from 'path'
import {sum, zipWith} from 'remeda'
export async function day1Part1() {
const input = await Bun.file(path.join(__dirname,'input.txt')).text()
const input = await Bun.file(path.join(__dirname, 'input.txt')).text()
const lines = input.split('\n')
const column1: number[] = []
const column2: number[] = []
@@ -17,12 +18,13 @@ export async function day1Part1() {
let result = 0
for(let i=0; i< column1.length; i++){
for (let i = 0; i < column1.length; i++) {
const left = column1[i]
const right = column2[i]
const diff = Math.abs(left - right)
result += diff
}
const foo = sum(zipWith(column1, column2, (a, b) => Math.abs(a - b)))
console.log({result})
console.log({result, foo})
}