this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 77 lines 2.0 kB view raw
1var expect = require('chai').expect; 2var Day7 = require('../lib/day7'); 3 4describe('Day7', function() { 5 6 it('does the thing', function() { 7 var instructions = [ 8 'x AND y -> d', 9 'x OR y -> e', 10 '123 -> x', 11 '456 -> y', 12 'x LSHIFT 2 -> f', 13 'y RSHIFT 2 -> g', 14 'NOT x -> h', 15 'NOT y -> i' 16 ]; 17 18 instructions.forEach(function(instruction) { 19 Day7.processInstruction(instruction); 20 }); 21 22 expect(Day7.getWireSignal('x')).to.equal(123); 23 expect(Day7.getWireSignal('y')).to.equal(456); 24 expect(Day7.getWireSignal('d')).to.equal(72); 25 expect(Day7.getWireSignal('e')).to.equal(507); 26 expect(Day7.getWireSignal('f')).to.equal(492); 27 expect(Day7.getWireSignal('g')).to.equal(114); 28 expect(Day7.getWireSignal('h')).to.equal(65412); 29 expect(Day7.getWireSignal('i')).to.equal(65079); 30 }); 31 32 33 describe('#parseParts', function() { 34 it('breaks instruction into parts', function() { 35 var instruction1 = 'fl LSHIFT 1 -> gf'; 36 var instruction2 = '1 AND ds -> dt'; 37 var instruction3 = 'NOT kt -> ku'; 38 var instruction4 = 'lv LSHIFT 15 -> lz'; 39 var instruction5 = 'la -> aa'; 40 41 expect(Day7.parseParts(instruction1)).to.eql({ 42 input1: 'fl', 43 input2: 1, 44 operation: 'LSHIFT', 45 output: 'gf' 46 }); 47 48 expect(Day7.parseParts(instruction2)).to.eql({ 49 input1: 1, 50 input2: 'ds', 51 operation: 'AND', 52 output: 'dt' 53 }); 54 55 expect(Day7.parseParts(instruction3)).to.eql({ 56 input1: null, 57 input2: 'kt', 58 operation: 'NOT', 59 output: 'ku' 60 }); 61 62 expect(Day7.parseParts(instruction4)).to.eql({ 63 input1: 'lv', 64 input2: 15, 65 operation: 'LSHIFT', 66 output: 'lz' 67 }); 68 69 expect(Day7.parseParts(instruction5)).to.eql({ 70 input1: 'la', 71 input2: null, 72 operation: null, 73 output: 'aa' 74 }); 75 }); 76 }); 77});