errmeier's recent activity

  1. Comment on Day 8: Seven Segment Search in ~comp

    errmeier
    Link
    Little bit late to this, but I'm proud of my solution for Part 2. The basic idea I went for was trying to identify the minimum amount of information needed to distinguish each of the digits. The...

    Little bit late to this, but I'm proud of my solution for Part 2. The basic idea I went for was trying to identify the minimum amount of information needed to distinguish each of the digits. The four factors I narrowed it down to were the length of the combination and the number of segments in common with the displays for 1, 4, and 7.
    Part 1: 80 bytes
    Part 2: 328 bytes

    Part 1
    print(sum(len(c)in(2,3,4,7) for I in open(0) for c in I.split('|')[1].split()))
    
    Part 2
    O={'6233':'0','2222':'1','5122':'2','5233':'3','4224':'4','5123':'5','6123':'6','3232':'7','7234':'8','6234':'9'}
    t = 0
    for I in open(0):l,r=I.strip().split('|');m={len(p):set(p) for p in l.split() if len(p) in (2,3,4)};t+=int(''.join(O[str(len(c))+''.join(str(len(set(c)&m[i])) for i in (2,3,4))] for c in r.split()))
    print(t)
    
    3 votes