Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
seven_segment solution in Clear category for Seven Segment by dannedved
digits = {
'0' : 'abcdef',
'1' : 'bc',
'2' : 'abdeg',
'3' : 'abcdg',
'4' : 'bcfg',
'5' : 'acdfg',
'6' : 'acdefg',
'7' : 'abc',
'8' : 'abcdefg',
'9' : 'abcdfg'
}
lowercase = {'a', 'b', 'c', 'd', 'e', 'f', 'g'}
def seven_segment(lit_seg, broken_seg):
first_lit = lit_seg - lowercase
firsts = [i for i in digits if set(digits[i].upper()).issubset(lit_seg | broken_seg)
and first_lit.issubset(set(digits[i].upper()))]
second_lit = lit_seg & lowercase
seconds = [i for i in digits if set(digits[i]).issubset(lit_seg | broken_seg)
and second_lit.issubset(set(digits[i]))]
return len([i + j for i in firsts for j in seconds])
if __name__ == '__main__':
assert seven_segment({'B', 'C', 'b', 'c'}, {'A'}) == 2, '11, 71'
assert seven_segment({'B', 'C', 'a', 'f', 'g', 'c', 'd'}, {'A', 'G', 'D', 'e'}) == 6, '15, 16, 35, 36, 75, 76'
assert seven_segment({'B', 'C', 'a', 'f', 'g', 'c', 'd'}, {'A', 'G', 'D', 'F', 'b', 'e'}) == 20, '15...98'
print('"Run" is good. How is "Check"?')
April 30, 2019