Skip to content

Reintroduce code from previous days #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/js/aoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,31 @@
/**
* Day 1
*/
function computeResult(contents) {
return getSumOfTopElves(contents, 1);
}

function getSumOfTopElves(contents, n) {
var globalResult = 0;
return globalResult;
}

/**
* Day 2
*/
function getScore(strategy)} {
var score = 0;
return score;
}

function getWeaponValue(score, opponent) {
return 1;
}

function getItemValue(item) {
var value = 0;
return value;
}

/**
* Day 3
Expand Down
64 changes: 61 additions & 3 deletions src/js/test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,67 @@
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', () => {
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 Three of Advent of Code', () => {
Expand Down Expand Up @@ -95,4 +153,4 @@ suite('Day Four of Advent of Code', () => {
chai.assert.deepEqual([34,35,36], getArrayInterval(34,36));
chai.assert.deepEqual([42], getArrayInterval(42));
});
});
});