Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
sets and sum of bools solution in Clear category for Seven Segment by Phil15
LOW_LIGHTS = {'abcdef', 'bc', 'abged', 'abgcd', 'fgbc',
'afgcd', 'acdefg', 'abc', 'abcdefg', 'abcdfg'} # 0 to 9 lights
UPP_LIGHTS = {light.upper() for light in LOW_LIGHTS}
count = lambda lits, lights, broken: sum(lits == set(light) - broken
for light in lights)
def seven_segment(lit, broken):
low, upp = lit & set('abcdefg'), lit & set('ABCDEFG')
return count(low, LOW_LIGHTS, broken) * count(upp, UPP_LIGHTS, broken)
Nov. 4, 2018