one big repo for all years

This commit is contained in:
Joshua Seigler 2021-12-02 15:52:52 -05:00
parent 4e1cd98bf1
commit ccc3cdba3a
9 changed files with 0 additions and 0 deletions

1
2020/day07.js Normal file
View file

@ -0,0 +1 @@
G="shiny gold",L=$`body`.innerText.trim().split`\n`.map(a=>/(.+) bags? contain (.*)\./.exec(a)),B=new Map(L.map(([,a,c])=>[a,[...c.matchAll(/(\d+) (.+?) bags?/g)]])),P=new Map,S=a=>(r=P.get(a),new Set(r?r.reduce((a,b)=>[...a,...S(b)],r):[])),E=a=>(B.get(a)||[]).reduce((a,[,b,d])=>a+1*b*E(d),1),B.forEach((a,b)=>a.forEach(([,,a])=>P.set(a,[...(P.get(a)||[]),b]))),[S(G).size,E(G)-1];