35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import {Oasis} from "./day_nine";
|
|
|
|
describe('Day Nine', () => {
|
|
const input = `0 3 6 9 12 15
|
|
1 3 6 10 15 21
|
|
10 13 16 21 30 45`;
|
|
|
|
it.each([
|
|
[[0, 3, 6, 9, 12, 15], 18],
|
|
[[1, 3, 6, 10, 15, 21], 28],
|
|
[[10, 13, 16, 21, 30, 45], 68]
|
|
])('It should get the next value in the sequence', (sequence, expected) => {
|
|
const oasis = new Oasis(input);
|
|
expect(oasis.getNextValueInSequence(sequence)).toEqual(expected);
|
|
});
|
|
|
|
it('should get the total of the next values in each sequence', () => {
|
|
const oasis = new Oasis(input);
|
|
expect(oasis.getTotalOfNextValuesInSequences()).toEqual(114);
|
|
});
|
|
|
|
it.each([
|
|
[[0, 3, 6, 9, 12, 15], -3],
|
|
[[1, 3, 6, 10, 15, 21], 0],
|
|
[[10, 13, 16, 21, 30, 45], 5]
|
|
])('It should get the previous value in the sequence', (sequence, expected) => {
|
|
const oasis = new Oasis(input);
|
|
expect(oasis.getPreviousValueInSequence(sequence)).toEqual(expected);
|
|
});
|
|
|
|
it('should get the total of the previous values in each sequence', () => {
|
|
const oasis = new Oasis(input);
|
|
expect(oasis.getTotalOfPreviousValuesInSequences()).toEqual(2);
|
|
});
|
|
}); |