From 46ae00bccc5f4010b61b417af2c0de9cdabd0b0e Mon Sep 17 00:00:00 2001 From: Joshua Seigler Date: Thu, 3 Dec 2020 22:46:39 -0500 Subject: [PATCH] Days 1-3 --- day01.js | 1 + day02.js | 2 ++ day03.js | 2 ++ 3 files changed, 5 insertions(+) create mode 100644 day01.js create mode 100644 day02.js create mode 100644 day03.js diff --git a/day01.js b/day01.js new file mode 100644 index 0000000..5558045 --- /dev/null +++ b/day01.js @@ -0,0 +1 @@ +let d=document.body.textContent.trim().split('\n').map(a=>parseInt(a)),s=0,f=(a,b,c=2)=>{for(let e,g,h=0;hl.match(/(.+)-(.+) (.): (.+)$/));[d.reduce((s,[_,l,u,n,h])=>{const c=[...h.matchAll(RegExp(n,'g'))].length;return c<=u&&c>=l?s+1:s},0),d.reduce((s,[_,a,b,n,h])=>{return h[a-1]==n^h[b-1]==n?s+1:s},0)]; \ No newline at end of file diff --git a/day03.js b/day03.js new file mode 100644 index 0000000..95ca691 --- /dev/null +++ b/day03.js @@ -0,0 +1,2 @@ +let d=document.body.textContent.trim().split(` +`);let t=(X,Y)=>{let c=0;for(let y=0,x=0;y