File tree Expand file tree Collapse file tree 3 files changed +23
-4
lines changed Expand file tree Collapse file tree 3 files changed +23
-4
lines changed Original file line number Diff line number Diff line change 1+ const { loadInput } = require ( './helpers' )
2+ const {
3+ parseEntry,
4+ sortInstructions
5+ } = require ( './steps' )
6+
7+ const init = ( data ) => {
8+ data = data . map ( parseEntry )
9+ const answer = sortInstructions ( parseEntry ) . map ( ( el ) => el . id ) . join ( '' )
10+ console . log ( `-- Part 1 --` )
11+ console . log ( `Answer: ${ answer } ` )
12+ console . log ( `-- Part 2 --` )
13+ // console.log(`Answer: ${answer2}`)
14+ }
15+
16+ loadInput ( init )
Original file line number Diff line number Diff line change 66 * @returns {Object } structured data
77 */
88const parseEntry = ( line , idx , arr ) => {
9- let entry = { }
10- return entry
9+ let data = line . split ( ' ' )
10+ return {
11+ id : data [ 7 ] ,
12+ dep : data [ 1 ]
13+ }
1114}
1215
1316/**
Original file line number Diff line number Diff line change @@ -16,14 +16,14 @@ Step F must be finished before step E can begin.`.split('\n')
1616describe ( '--- Day 7: The Sum of Its Parts ---' , ( ) => {
1717 describe ( 'Part 1:' , ( ) => {
1818 describe ( 'parseEntry' , ( ) => {
19- it . skip ( 'Parses a line of the log to create a structured data object representing the entry' , ( ) => {
19+ it ( 'Parses a line of the log to create a structured data object representing the entry' , ( ) => {
2020 const test = testData [ 4 ]
2121 const expected = {
2222 id : 'E' ,
2323 dep : 'B'
2424 }
2525 const actual = parseEntry ( test )
26- expect ( actual ) . to . equal ( expected )
26+ expect ( actual ) . to . deep . equal ( expected )
2727 } )
2828 } )
2929 describe ( 'sortInstructions()' , ( ) => {
You can’t perform that action at this time.
0 commit comments