Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
frozensets solution in Clear category for Seven Segment by David_Jones
DIGITS = set(map(frozenset, ('BC', 'ABDEG', 'ABCDG', 'BCFG', 'ACDFG',
'ACDEFG', 'ABC', 'ABCDEFG', 'ABCDFG', 'ABCDEF')))
possible_digits = lambda A, B: sum(A <= X <= B for X in DIGITS)
def seven_segment(lit_seg, broken_seg):
lit_1, lit_2 = set(), set()
for seg in lit_seg:
if seg.isupper():
lit_1.add(seg)
else:
lit_2.add(seg.upper())
all_1, all_2 = set(lit_1), set(lit_2)
for seg in broken_seg:
if seg.isupper():
all_1.add(seg)
else:
all_2.add(seg.upper())
return possible_digits(lit_1, all_1) * possible_digits(lit_2, all_2)
May 13, 2019