github.com/cycloss/advent-of-code@v0.0.0-20221210145555-15039b95faa6/2021/day8/day8Strategy.md (about) 1 # Day 8 Strategy 2 3 ## Algorithm With Example 4 5 acedgfb cdfbe gcdfa fbcad dab cefabd cdfgeb eafb cagedb ab 6 7 - ab is 1, dab is 7, eafb is 4, acedgfb is 8 8 - 6 segs: cefabd cdfgeb cagedb 9 - 5 segs: cdfbe gcdfa fbcad 10 - top seg: not common to 1 and 7: d 11 - bottom seg: common to 6 segs: c e b d, not in 4 c, d, not top seg: c 12 - bottom left seg: not in 1, 4, 7: c? g?: g 13 - top right: in 1 but only 2 of 6 segs: a 14 - bottom right: b 15 - middle: common to 5 segs c, d, f, not known: f 16 - top left remaining not known: e 17 - **correct 18 19 - create sets for known 1, 4, 7 and 8 20 - create array of sets for 5 and 6 sets 21 22 dddd 23 e a 24 e a 25 ffff 26 g b 27 g b 28 cccc 29 30 aaaa 31 b c 32 b c 33 dddd 34 e f 35 e f 36 gggg 37 38 // unique: 1 cf, 4 bcdf, 7 acf, 8 a-g 39 // non unique: [6seg 0, 6, 9], [5seg 2,3, 5] 40 // top segment is one not common to 1 and 7 41 // bottom seg will be present in all the 6 segs, but not in 4, and isn't the top seg 42 // bottom left seg is only one present in 8 but not in 1 4 and 7 and isn't the bottom seg 43 // top right is present in 1, and only 2 of the 6 segs 44 // now know bottom right as is not top right of 1 45 // middle seg is common to all 5 segs and not known 46 // top left seg is only one not known in 4