this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Backfill for day 1

+68 -8
+16 -4
index.js
··· 1 1 var fs = require('fs'); 2 2 3 + /** 4 + * Day 1! 5 + * ---------------------------------- 6 + */ 7 + var Day1 = require('./lib/day1'); 8 + var day1Input = fs.readFileSync('./input/day1.txt', 'utf8'); 9 + var day1Part1Answer = require('./lib/day1').floorCount(day1Input); 10 + var day1Part2Answer = require('./lib/day1').entersBasementAt(day1Input); 11 + console.log('Day 1, Part 1:', day1Part1Answer); 12 + console.log('Day 1, Part 2:', day1Part2Answer); 13 + 3 14 // TODO: Go back and redo days 1 - 3, for consistency :) 4 15 5 16 /** 6 17 * Day 4! 7 18 * ---------------------------------- 8 19 */ 20 + var Day4 = require('./lib/day4'); 9 21 var day4Input = fs.readFileSync('./input/day4.txt', 'utf8').replace(/[^A-z0-9]/g, ''); 10 - var day4Part1Answer = require('./lib/day4').getTheAnswer(day4Input, '00000'); 11 - var day4Part2Answer = require('./lib/day4').getTheAnswer(day4Input, '000000'); 12 - console.log('Day 4, Part 1: ', day4Part1Answer); 13 - console.log('Day 4, Part 2: ', day4Part2Answer); 22 + var day4Part1Answer = Day4.adventCoinSecret(day4Input, '00000'); 23 + var day4Part2Answer = Day4.adventCoinSecret(day4Input, '000000'); 24 + console.log('Day 4, Part 1:', day4Part1Answer); 25 + console.log('Day 4, Part 2:', day4Part2Answer);
+1
input/day1.txt
··· 1 + ((((()(()(((((((()))(((()((((()())(())()(((()((((((()((()(()(((()(()((())))()((()()())))))))))()((((((())((()))(((((()(((((((((()()))((()(())()((())((()(()))((()))()))()(((((()(((()()))()())((()((((())()())()((((())()(()(()(((()(())(()(())(((((((())()()(((())(()(()(()(())))(()((((())((()))(((()(()()(((((()()(()(((()(((((())()))()((()(()))()((()((((())((((())(()(((())()()(()()()()()(())((((())((())(()()))()((((())))((((()())()((((())((()())((())(())(((((()((((()(((()((((())(()(((()()))()))((((((()((())()())))(((()(()))(()()(()(((()(()))((()()()())((()()()(((())())()())())())((()))(()(()))(((((()(()(())((()(())(())()((((()())()))((((())(())((())())((((()(((())(())((()()((((()((((((()(())()()(()(()()((((()))(())()())()))(())))(())))())()()(())(()))()((()(()(())()()))(()())))))(()))(()()))(())(((((()(()(()()((())()())))))((())())((())(()(())((()))(())(((()((((((((()()()(()))()()(((()))()((()()(())(())())()(()(())))(((((()(())(())(()))))())()))(()))()(()(((((((()((((())))())())())())()((((((((((((((()()((((((()()()())())()())())())(())(())))())((()())((()(()))))))()))))))))))))))))())((())((())()()))))))(((()((()(()()))((())(()()))()()())))(())))))))(()(((())))())()())))()()(())()))()(()))())((()()))))(()))))()))(()()(())))))))()(((()))))()(()))(())())))))()))((()))((()))())(())))))))))((((())()))()))()))())(())()()(())))())))(()())()))((()()(())))(())((((((()(())((()(((()(()()(())))()))))))()))()(()((()))()(()))(()(((())((((())())(())(()))))))))())))))))())())))))())))))()()(((())()(()))))))))())))))(())()()()))()))()))(()(())()()())())))))))())()(()(()))))()()()))))())(()))))()()))))()())))))(((())()()))(()))))))))))()()))))()()()))))(()())())()()())()(()))))()(()))(())))))))(((((())(())())()()))()()))(())))))()(()))))(())(()()))()())()))()))()))()))))())()()))())())))(()))(()))))))())()(((())()))))))))()))()())))())))())))()))))))))))()()))(()()))))))(())()(()))))())(()))))(()))))(()())))))())())()()))))())()))))))))(()))))()))))))()(()())))))))()))())))())))())))())))))))())(()()))))))(()())())))()())()))))))))))))))())))()(())))()))())()()(())(()()))(())))())()())(()(()(()))))())))))))))))())(()))()))()))))(())()())()())))))))))))()()))))))))))))())())))))(()())))))))))))())(())))()))))))))())())(()))()))(())))()))()()(())()))))))()((((())()))())())))))()))()))))((()())()))))())))(())))))))))))))))))()))))()()())()))()()))))())()))((()())))())))(()))(()())))))))()))()))))(())))))))(())))))())()()(()))())()))()()))))())()()))))())()))())))))))(()))))()())()))))))))(()))())))(()))()))))(())()))())())(())())())))))))((((())))))()))()))()())()(())))()))()))()())(()())()()(()())()))))())())))))(()))()))))())(()()(())))))(())()()((())())))))(())(())))))))())))))))))()(())))))))()())())())()(()))))))))(()))))))))())()()))()(()))))))()))))))())))))))(())))()()(())()())))))(((())))()((())()))())))(()()))())(())())))()(((()())))))()(()()())))()()(()()(()()))())()(()()()))())()()))()())(()))))())))))())))(())()()))))(()))))(())(()))(())))))()()))()))))())()))()()(())())))((()))())()))))))()()))))((()(()))))()()))))))())))))())(()((()())))))))))))()())())))()))(()))))))(()))(())()())))(()))))))))())()()()()))))(()())))))))((())))()))(()))(())(())()())()))))))))(())))())))(()))()()))(()()))(()))())))()(())))())((()((()(())))((())))()))))((((())())()())))(())))()))))))())(()()((())))())()(()())))))(()())()))())))))))((())())))))))(()(()))())()()(()()(((()(((()())))))()))))))()(())(()()((()()(())()()))())()())()))()())())())))))))(((())))))))()()))))))(((())()))(()()))(()()))))(()(()()((((())()())((()()))))(()(())))))()((()()()())()()((()((()()))(()))(((()()()))(((())))()(((())()))))))((()(())())))(()())(((((()(()))(()((()))(()())()))))(()(()))()(()))(())(((())(()()))))()()))(((()))))(()()()()))())))((()()()(())()))()))))()()))()))))))((((((()()()))))())((()()(((()))))(()(())(()()())())())))()(((()()))(())((())))(()))(()()()())((())())())(()))))()))()((()(())()(()()(())(()))(())()))(())(()))))(())(())())(()()(()((()()((())))((()))()((())))(((()()()()((((()))(()()))()()()(((())((())())(()()(()()()))()((())(())()))())(((()()(())))()((()()())()())(()(())())(((())(())())((())(())()(((()()))(())))((())(()())())(())((()()()((((((())))((()(((((())()))()))(())(()()))()))(())()()))(())((()()())()()(()))())()((())))()((()()())((((()())((())())())((()((()))()))((())((()()(()((()()(((())(()()))))((()((())()(((())(()((())())((())(()((((((())())()(()())()(())(((())((((((()(())(()((()()()((()()(()()()())))()()(((((()()))()((((((()))()(()(()(()(((()())((()))())()((()))(())))()))()()))())()()))())((((())(()(()))(((((((())(((()(((((()(((()()((((())(((())())))(()()()(()(()))()))((((((()))((()(((()(())((()((((()((((((())(((((())))(((()(()))))(((()(((())()((())(()((()))(((()()(((())((((()(()(((((()))(((()(((((((()(()()()(()(()(()()())(())(((((()(())())()())(()(()(()))()(()()()())(()()(()((()))()((())())()(()))((())(()))()(()))()(((()(()(()((((((()()()()())()(((((()()(((()()()((()(((((()))((((((((()()()(((((()))))))(()()()(())(()))(()()))))(())()))(((((()(((((()()(()(()())(((()))((((()((()(()(()((()(()((())))()(((()((()))((()))(((((((((()((()((()(())))()((((()((()()))((())(((()(((((()()(()(()()((()(()()()(((((((())())()())))))((((()()(()))()))(()((())()(()(((((((((()()(((()(()())(()((()())((())())((((()(((()(((()((((()((()((((()(()((((((())((((((((((((()()(()()((((((((((((((()((()()))()((((((((((((())((((()(()())((()(()(()))()(((((()()(((()()))()())(())((()(((((()((())(((((()((()(((((()))()()((((())()((((())(((((((((()(())(()(())))())(()((())(((())(())(())())(()(()(())()()((()((())()(((()(((((()(())))()(((()((())))((()()()(((()(((()((()(()(())(()((()())(()(()(((()(((((((((())(()((((()()))(()((((()()()()(((()((((((((()(()()((((((()(()()(()((()((((((((((()()(((((((()())(())))(((()()))(((((()((()()())(()()((((())((()((((()))))(())((()(()()(((()(()(((()((((()(((((()))())())(()((())()))(((()())((())((())((((()((()((((((())(()((((()()))((((((())()(()))((()(((())((((((((((()()(((((()(((((()((()()()((((())))(()))()((()(())()()((()((((((((((()((())(())(((((()(()(()()))((((()((((()()((()(((()(((((((((()(()((()((()))((((((()(((())()()((()(((((((()())))()()(()((()((()()(((()(()()()()((((()((())((((()(((((((((()(((()()(((()(()(((()(((()((())()(()((()(()(()(()))()(((()))(()((((()((())((((())((((((())(()))(()((((())((()(()((((((((()()((((((()(()(()()()(())((()((()()(((()(((((((()()((()(((((((()))(((((()(((()(()()()(()(((()((()()((())(()(((((((((()(()((()((((((()()((())()))(((((()((())()())()(((((((((((()))((((()()()()())(()()(()(()()))()))(()))(()(((()()))())(()(()))()()((())(()())()())()(()))()))(()()(()((((((())((()(((((((((((()(())()((()(()((()((()(()((()((((((((((()()())((())()(())))((())()())()(((((()(()())((((()((()(())(()))(((())()((()))(((((())(()))()()(()))(((())((((()((((()(())))(((((((()))))())()())(())((())()(()()((()(()))()(()()(()()((()())((())((()()))((((()))()()))(()()(())()()(((((()(())((()((((()))()))(()())())(((()()(()()))(())))))(()))((())(((((()((((()))()((((()))()((())(((())))(((()())))((()(()()((
+26
lib/day1.js
··· 1 + module.exports = { 2 + floorCount: function(input) { 3 + var floor = 0; 4 + 5 + input.split('').forEach((movement) => { 6 + if (movement === '(') floor++; 7 + if (movement === ')') floor--; 8 + }); 9 + 10 + return floor; 11 + }, 12 + entersBasementAt: function(input) { 13 + var floor = 0, 14 + basementAt = null; 15 + 16 + input.split('').forEach((movement, idx) => { 17 + if (movement === '(') floor++; 18 + if (movement === ')') floor--; 19 + if (!basementAt && floor === -1) { 20 + basementAt = idx + 1; 21 + } 22 + }); 23 + 24 + return basementAt; 25 + } 26 + };
+1 -1
lib/day4.js
··· 2 2 var fs = require('fs'); 3 3 4 4 module.exports = { 5 - getTheAnswer: function(input, frontPadding) { 5 + adventCoinSecret: function(input, frontPadding) { 6 6 var hash = '', 7 7 answer = -1; 8 8
+19
spec/day1.spec.js
··· 1 + var Day1 = require('../lib/day1'); 2 + 3 + var expect = require('chai').expect; 4 + 5 + describe('Day1', function() { 6 + describe('#floorCount', function() { 7 + it('returns appropriate floor count from input', function() { 8 + expect(Day1.floorCount('(((())')).to.equal(2); 9 + expect(Day1.floorCount('))))')).to.equal(-4); 10 + }); 11 + }); 12 + 13 + describe('#entersBasementAt', function() { 14 + it('returns the char position when first entering basement', function() { 15 + expect(Day1.entersBasementAt(')')).to.equal(1); 16 + expect(Day1.entersBasementAt('((())))(()))')).to.equal(7); 17 + }); 18 + }); 19 + });
+5 -3
spec/day4.spec.js
··· 2 2 3 3 var Day4 = require('../lib/day4'); 4 4 5 - describe('getTheAnswer', function() { 6 - it('returns the correct answer', function() { 7 - expect(Day4.getTheAnswer('abcdef', '00000')).to.equal(609043); 5 + describe('Day4', function() { 6 + describe('#adventCoinSecret', function() { 7 + it('returns the correct answer', function() { 8 + expect(Day4.adventCoinSecret('abcdef', '00000')).to.equal(609043); 9 + }); 8 10 }); 9 11 });