Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
~0my3[_p\x7f{ solution in Creative category for Seven Segment by skunkfrukt
SEGMENTS_PER_DIGIT = [*map(ord, "~0my3[_p\x7f{")]
ALL_SEGMENTS = 0x7f
SEGMENT_NAMES_PER_POSITION = ["ABCDEFG", "abcdefg"]
def seven_segment(lit_segment_names, broken_segment_names):
result = 1
for segment_names in SEGMENT_NAMES_PER_POSITION:
lit_segments, broken_segments = [
int("".join(
"01"[segment_name in segment_name_set]
for segment_name in segment_names
), 2)
for segment_name_set in (lit_segment_names, broken_segment_names)
]
unlit_segments = ALL_SEGMENTS & ~(lit_segments | broken_segments)
matching_digits_for_position = [
segments_in_digit for segments_in_digit in SEGMENTS_PER_DIGIT
if segments_in_digit & lit_segments == lit_segments
and segments_in_digit & unlit_segments == 0
]
result *= len(matching_digits_for_position)
return result
July 18, 2019
Comments: