diff --git a/src/js/aoc.js b/src/js/aoc.js
index 031e84b..462c7cb 100644
--- a/src/js/aoc.js
+++ b/src/js/aoc.js
@@ -15,6 +15,14 @@
/**
* Day 1
*/
+function computeResult(contents) {
+ return getSumOfTopElves(contents, 1);
+}
+
+function getSumOfTopElves(contents, n) {
+ var globalResult = 0;
+ return globalResult;
+}
/**
* Day 2
@@ -178,7 +186,6 @@ function getArrayInterval(start, end) {
return result;
}
-
/**
* --- Day 7 : Directory size ---
*/
@@ -256,6 +263,7 @@ function getVisibleTrees(forest) {
/**
* --- Day 9: Get tail position ---
*/
+
function getNumberTailPositions(motionList) {
var position = [0, 0];
var tailPositions = [];
@@ -361,4 +369,4 @@ function isRelated(positionHead, positionTail) {
}
}
return false;
-}
+}
\ No newline at end of file
diff --git a/src/js/test.js b/src/js/test.js
index 40286d9..e081818 100644
--- a/src/js/test.js
+++ b/src/js/test.js
@@ -1,8 +1,68 @@
mocha.setup('tdd');
-suite('Day One of Advent of Code', () => {
+suite('Day one of Advent of Code', () => {
+ var contentTestInput = `
+1000
+2000
+3000
+
+4000
+
+5000
+6000
+
+7000
+8000
+9000
+
+10000`;
+
+ test('The elf with the most calories carry 24000 calories', () => {
+ chai.expect(getSumOfTopElves(contentTestInput, 1)).to.eql(24000);
+ });
+
+ test('The sum of the Calories carried by the top three elves is 45000', () => {
+ chai.expect(getSumOfTopElves(contentTestInput, 3)).to.eql(45000);
+ });
});
+suite('Day two of Advent of Code', () => {
+ var strategy = `A Y
+B X
+C Z
+`;
+
+ test('the rock scissor paper score based on the strategy will return 15', () => {
+ chai.assert.equal(12, getScore(strategy));
+ });
+
+ test('the detailed score should work', () => {
+ chai.assert.equal(7, getScore('C Z'));
+ chai.assert.equal(4, getScore('A Y'));
+ chai.assert.equal(1, getScore('B X'));
+ chai.assert.equal(3, getScore('A X'));
+ });
+
+ test('the rock is valued to 1', () => {
+ chai.assert.equal(1, getItemValue('A'));
+ });
+ test('the paper is valued to 2', () => {
+ chai.assert.equal(2, getItemValue('B'));
+ });
+ test('the scissor is valued to 3', () => {
+ chai.assert.equal(3, getItemValue('C'));
+ });
+
+ test('ho no, i lose', () => {
+ chai.assert.equal(0, getResultScore('X'));
+ });
+ test('this was close', () => {
+ chai.assert.equal(3, getResultScore('Y'));
+ });
+ test('yeah I win', () => {
+ chai.assert.equal(6, getResultScore('Z'));
+ });
+
suite('Day Two of Advent of Code', () => {
});
diff --git a/src/js/test/day_8.js b/src/js/test/day_8.js
new file mode 100644
index 0000000..b9e4d26
--- /dev/null
+++ b/src/js/test/day_8.js
@@ -0,0 +1,13 @@
+mocha.setup('tdd');
+
+suite('Day eight of Advent of Code', () => {
+ const testData = `30373
+25512
+65332
+33549
+35390`;
+
+ test('There\'s 21 tree visible from outside the grid', () => {
+ chai.assert.equal(21, getVisibleTrees(testData));
+ });
+});
diff --git a/src/js/test/day_9.js b/src/js/test/day_9.js
index abe042b..1f97e4a 100644
--- a/src/js/test/day_9.js
+++ b/src/js/test/day_9.js
@@ -37,6 +37,4 @@ R 2`;
chai.assert.isFalse(iNeedToMoveTail(data[0], data[1]));
});
});
-
-
});
diff --git a/src/test.html b/src/test.html
index 37d81b4..0288e64 100644
--- a/src/test.html
+++ b/src/test.html
@@ -18,6 +18,7 @@
+