```#!/usr/bin/env kuroko
'''
Day 8, Part 2

Part 1 removed, mostly because I didn't keep the code around for it.
'''

## Common template, load data
import fileio, kuroko
let lines
with fileio.open(kuroko.argv if len(kuroko.argv) > 1 else kuroko.argv.replace('.krk','.txt'),'r') as f:
lines = [line.strip() for line in f.readlines()]

def bitand(c, m):
for x in m:
if x not in c:
return False
return True

let out = []
for c in candidate:
if c not in mask:
out.append(c)
return out

let output = 0
for line in lines:
let left, right = [x.strip() for x in line.split(' | ')]

let stuff = left.split(' ')
let outs = right.split(' ')

let digits = {}

let comb = [''.join(sorted(x)) for x in stuff]
comb.extend([''.join(sorted(x)) for x in outs])

# 1, 4, 7, 8 have Unique lengths
for x in comb:
if len(x) == 2:
digits = x
else if len(x) == 3:
digits = x
else if len(x) == 4:
digits = x
else if len(x) == 7:
digits = x

# 0, 9, and 6 have 6 segments and unique overlaps against 4 and 1
for x in comb:
if len(x) == 6:
if bitand(x, digits):
digits = x
else if bitand(x, digits):
digits = x
else:
digits = x

# 5 is the only 5-segment that overlaps with 6
for x in comb:
if len(x) == 5 and bitand(digits, x):
digits = x

# 2 and 3 have different numbers of strokes that aren't on the right
for x in comb:
if len(x) == 5 and x != digits:
let count = len(minus(x,digits))
if count == 3:
digits = x
else if count == 4:
digits = x

let backwards = {}
for k,v in digits.items():
backwards[v] = str(k)

let digit = ''.join(backwards[''.join(sorted(i))] for i in outs)
output += int(digit)

# Part 2
print(output)
```