Created
December 2, 2018 22:06
-
-
Save willowiscool/cf1f8a51ca92ebfce9cb7d547c5acd23 to your computer and use it in GitHub Desktop.
Advent of Code 2018... GOLFED!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is my list of solutions to the Advent of Code challanges | |
// They are written in JavaScript, with the goal of getting the | |
// size of them to be as small as possible. | |
// Each one assumes that the variable y is an array of the body's | |
// contents. You can get that by doing the following in the | |
// browser console of the input: | |
y=document.body.innerText.split("\n") | |
// The documents may have a trailing newline, but you can do this | |
// to solve that | |
y=y.slice(0,y.length-1) | |
// DAY 1, PART 1 | |
y.map(Number).reduce((a,b)=>a+b) | |
// returns the answer | |
// DAY 1, PART 2 | |
// I lost this code and am too lazy to recreate it right now | |
// DAY 2, PART 1 | |
t=0;f=0;for(i of y){s={};for(o of i)s[o]?s[o]++:s[o]=1;q=Object.values(s);q.includes(2)?t++:0;q.includes(3)?f++:0}f*t | |
// DAY 2, PART 2 | |
meh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment