Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
nothing special solution in Clear category for Seven Segment by maybe
def seven_segment(lit_seg, broken_seg):
segU,segL = set('ABCDEFG'), set('abcdefg')
digitU=list(map(set,
['BC','ABGED','ABCGD','BCFG','ACDFG','ACDEFG',
'ABC','ABCDEFG','ABCDFG','ABCDEF']
))
digitL=list(map(set,map(str.lower,
['BC','ABGED','ABCGD','BCFG','ACDFG','ACDEFG',
'ABC','ABCDEFG','ABCDFG','ABCDEF']
)))
""" a digit is possible if
a) all lit segments belong to the digit AND
b) all segments of the digit are either lit or defective
"""
litU = lit_seg & segU
litL = lit_seg & segL
maybeU = (broken_seg & segU) | litU
maybeL = (broken_seg & segL) | litL
return ( sum( litU <= digit <= maybeU for digit in digitU)
* sum( litL <= digit <= maybeL for digit in digitL) )
Dec. 26, 2019