import {DesertMap, lcm} 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)` const ghostInput = `LR 11A = (11B, XXX) 11B = (XXX, 11Z) 11Z = (11B, XXX) 22A = (22B, XXX) 22B = (22C, 22C) 22C = (22Z, 22Z) 22Z = (22B, 22B) XXX = (XXX, XXX)` it('should calculate the number of steps needed to reach ZZZ', () => { const map = new DesertMap(input); expect(map.stepsToZ('AAA')).toEqual(2); }); it('should repeat the pattern', () => { const map = new DesertMap(repeatedInput); expect(map.stepsToZ('AAA')).toEqual(6); }); it('should count how many steps it takes to get from every node beginning with A, to every node ending in Z simultaneously', () => { const map = new DesertMap(ghostInput); expect(map.ghostStepsToZ()).toEqual(6); }); describe('lcm', () => { it('should get the correct lowest common multiple', () => { expect(lcm(12, 30)).toEqual(60); }); }); });