@@ -18,15 +18,16 @@ gcafb gcf dcaebfg ecagb gf abcdeg gaef cafbge fdbac fegbdc | fgae cfgab fg bagce
18
18
describe ( '--- Day 8: Seven Segment Search ---' , ( ) => {
19
19
describe ( 'Part 1' , ( ) => {
20
20
describe ( 'descrambleSignal()' , ( ) => {
21
- const testData = testSingle . split ( '|' ) [ 0 ] . trim ( )
22
- const { segmentCodes, charCodes } = descrambleSignal ( testData )
23
-
24
21
it ( 'takes scambled string of 10 codes and identifies the letters matching each seven-digit-display segment' , ( ) => {
22
+ const testData = testSingle . split ( '|' ) [ 0 ] . trim ( )
23
+ const { segmentCodes } = descrambleSignal ( testData )
25
24
expect ( segmentCodes . length ) . to . equal ( 7 )
26
25
expect ( segmentCodes . filter ( ( code ) => ! [ 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' ] . includes ( code ) ) . length ) . to . equal ( 0 )
27
26
} )
28
27
29
28
it ( 'produces a list of character codes for each number that can be displayed' , ( ) => {
29
+ const testData = testSingle . split ( '|' ) [ 0 ] . trim ( )
30
+ const { charCodes } = descrambleSignal ( testData )
30
31
// There should be exactly 10 numbers
31
32
expect ( charCodes . length ) . to . equal ( 10 )
32
33
// lengths of each code is predictable as each number has a specific count of segments
@@ -35,10 +36,9 @@ describe('--- Day 8: Seven Segment Search ---', () => {
35
36
} )
36
37
} )
37
38
describe ( 'decodeSignal()' , ( ) => {
38
- const testData = testMultiple [ 0 ] . split ( '|' ) . map ( ( a ) => a . trim ( ) )
39
- const { charCodes } = descrambleSignal ( testData [ 0 ] )
40
-
41
39
it ( 'decodes a display pattern using the provided map of display codes' , ( ) => {
40
+ const testData = testMultiple [ 0 ] . split ( '|' ) . map ( ( a ) => a . trim ( ) )
41
+ const { charCodes } = descrambleSignal ( testData [ 0 ] )
42
42
const result = decodeSignal ( charCodes , testData [ 1 ] )
43
43
expect ( result [ 0 ] ) . to . equal ( 8 )
44
44
expect ( result [ 3 ] ) . to . equal ( 4 )
0 commit comments