jamaik

aoc-d1

Dec 1st, 2021 (edited)
337
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. f="./inputs/day_1.txt"
  2. l=require("fs").readFileSync(f,"utf8").split("\n").map(eval)
  3. s=(i,z)=>l[i]+((!z&&(l[i-1]+l[i+1]))||0);r=z=>l.reduce((a,x,i)=>s(i,z)>s(i-1,z)?a+1:a,0)
  4. console.log(r(1),r())
  5.  
RAW Paste Data