Skip to content

Commit 17a6552

Browse files
fix(2021-day-08): the number 3 was not always descrambled
1 parent 156ca8e commit 17a6552

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

2021/day-08/display.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ const descrambleSignal = (data) => {
113113
.filter((code) => code.length === 5) // Find 5-character codes
114114
.filter((code) => {
115115
// Remove codes that don't include both segments of #1
116-
return code.filter((letter) => !number1.includes(letter)).length === 0
116+
return code.filter((letter) => !number1.includes(letter)).length === 3
117117
})[0]
118118

119119
console.debug('Found #3')
@@ -354,16 +354,19 @@ const descrambleSignal = (data) => {
354354
// )
355355

356356
// #4 is the only number we need that doesn't come from identifying segments
357+
console.debug('Find #4')
357358
findNum4()
358359

359360
// Find the codes for each segment
361+
console.debug('Find segment 0')
360362
findSeg0(
361363
findNum1(),
362364
findNum7()
363365
)
364366

365367
console.debug(segmentCodes)
366368

369+
console.debug('Find segment 1')
367370
findSeg1(
368371
findNum1(),
369372
findNum6(
@@ -373,6 +376,7 @@ const descrambleSignal = (data) => {
373376

374377
console.debug(segmentCodes)
375378

379+
console.debug('Find segment 2')
376380
findSeg2(
377381
findNum1(),
378382
findSeg1(
@@ -387,6 +391,7 @@ const descrambleSignal = (data) => {
387391

388392
// findSeg3 is moved to last because it depends on finding all other segments first
389393

394+
console.debug('Find segment 4')
390395
findSeg4(
391396
findNum1(),
392397
findNum5(
@@ -397,6 +402,7 @@ const descrambleSignal = (data) => {
397402

398403
console.debug(segmentCodes)
399404

405+
console.debug('Find segment 5')
400406
findSeg5(
401407
findNum1(),
402408
findNum2(
@@ -412,6 +418,7 @@ const descrambleSignal = (data) => {
412418

413419
console.debug(segmentCodes)
414420

421+
console.debug('Find segment 6')
415422
findSeg6(
416423
findNum0(
417424
findNum6(
@@ -432,6 +439,7 @@ const descrambleSignal = (data) => {
432439

433440
console.debug(segmentCodes)
434441

442+
console.debug('Find segment 3')
435443
findSeg3(
436444
findNum8(),
437445
segmentCodes

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy