Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Simple operations on sets solution in Clear category for Seven Segment by caldeius
def seven_segment(lit_seg, broken_seg):
normal_numbers_1 = [{'B','C'}, {'A','B','D','E','G'}, {'A','B','D','C','G'}, {'B','C','F','G'}, {'A','C','D','F','G'}]
normal_numbers_1 += [{'A','C','D','E','F','G'}, {'A','B','C'}, {'A','B','C','D','E','F','G'}, {'A','B','D','C','F','G'}, {'A','B','C','D','E','F'}]
normal_numbers_2 = [{'b','c'}, {'a','b','d','e','g'}, {'a','b','d','c','g'}, {'b','c','f','g'}, {'a','c','d','f','g'}]
normal_numbers_2 += [{'a','c','d','e','f','g'}, {'a','b','c'}, {'a','b','c','d','e','f','g'}, {'a','b','d','c','f','g'}, {'a','b','c','d','e','f'}]
broken_numbers_1 = [normal.difference(broken_seg) for normal in normal_numbers_1]
broken_numbers_2 = [normal.difference(broken_seg) for normal in normal_numbers_2]
lit_1 = {seg for seg in lit_seg if seg.isupper()}
lit_2 = {seg for seg in lit_seg if seg.islower()}
#replace this for solution
return broken_numbers_1.count(lit_1) * broken_numbers_2.count(lit_2)
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"?')
Jan. 23, 2020