Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for Seven Segment by wbl4126
DIGITS = [
0b0111111, # 'ABCDEF'
0b0000110, # 'BC'
0b1011011, # 'ABDEG'
0b1001111, # 'ABCDG'
0b1100110, # 'BCFG'
0b1101101, # 'ACDFG'
0b1111101, # 'ACDEFG'
0b0000111, # 'ABC'
0b1111111, # 'ABCDEFG'
0b1101111, # 'ABCDFG'
]
SEG = {chr(ord("A") + i): 0b1 << i for i in range(ord("G") - ord("A") + 1)}
def seven_segment(lit_seg, broken_seg):
cnt = 1
for func in [str.isupper, str.islower]:
l = sum([SEG[s.upper()] for s in filter(func, lit_seg)])
b = l | sum([SEG[s.upper()] for s in filter(func, broken_seg)])
cnt *= len([*filter(lambda x: x | b == b, filter(lambda x: x & l == l, DIGITS))])
return cnt
March 11, 2020
Comments: