Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
sum(1 for d in DIGITS if...) solution in Uncategorized category for Seven Segment by evsistr
DIGITS = ['abcdef',
'bc',
'abdeg',
'abcdg',
'bcfg',
'acdfg',
'acdefg',
'abc',
'abcdefg',
'abcdfg']
def seven_segment(lit_seg, broken_seg):
lit = [{x.lower() for x in lit_seg if x.isupper()}, {x.lower() for x in lit_seg if x.islower()}]
broken = [{x.lower() for x in broken_seg if x.isupper()}, {x.lower() for x in broken_seg if x.islower()}]
a = sum(1 for d in DIGITS if lit[0] <= set(d) <= (lit[0] | broken[0]))
b = sum(1 for d in DIGITS if lit[1] <= set(d) <= (lit[1] | broken[1]))
return a * b
if __name__ == '__main__':
seven_segment({'B', 'C', 'b', 'c'}, {'A'})
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"?')
Jan. 26, 2020
Comments: