Skip to content

Instantly share code, notes, and snippets.

@ChiriVulpes
Created December 6, 2024 09:42
Show Gist options
  • Save ChiriVulpes/9dfb1d69fd3fdda518918a20229d3cf6 to your computer and use it in GitHub Desktop.
Save ChiriVulpes/9dfb1d69fd3fdda518918a20229d3cf6 to your computer and use it in GitHub Desktop.
advent of code 2024 chiri solutions day 1
let d = input.split("\n").map(l => l.split(/\s+/g)),
a = d.map(([a])=>+a).sort((a,b)=>a-b),
b = d.map(([,b])=>+b).sort((a,b)=>a-b),
c = a.map((a, i) => Math.abs(a - b[i])),
o = c.reduce((c, v) => c + v, 0)
let d = input.split("\n").map(l => l.split(/\s+/g)),
a = i.map(([a])=>+a),
b = i.map(([,b])=>+b),
c = a.map(a=>a * b.filter(b=>b===a).length).reduce((c, v) => c + v, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment