advent-of-code-2023/src/day_eight.test.ts

29 lines
582 B
TypeScript
Raw Normal View History

import {DesertMap} from "./day_eight";
describe('Day Eight', () => {
const input = `RL
AAA = (BBB, CCC)
BBB = (DDD, EEE)
CCC = (ZZZ, GGG)
DDD = (DDD, DDD)
EEE = (EEE, EEE)
GGG = (GGG, GGG)
ZZZ = (ZZZ, ZZZ)`;
const repeatedInput = `LLR
AAA = (BBB, BBB)
BBB = (AAA, ZZZ)
ZZZ = (ZZZ, ZZZ)`
it('should calculate the number of steps needed to reach ZZZ', () => {
const map = new DesertMap(input);
expect(map.stepsTo('ZZZ')).toEqual(2);
});
it('should repeat the pattern', () => {
const map = new DesertMap(repeatedInput);
expect(map.stepsTo('ZZZ')).toEqual(6);
})
});