Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Pure solution in Clear category for Matrix-2-String by amandel
Row = tuple[int, int, int, int, int]
Grid = tuple[Row, Row, Row, Row, Row]
def converter(matrix: Grid) -> str:
return ''.join(chr(i+[ord('a'),ord('A')][x-1]) for i,x in enumerate(sum(matrix,tuple())) if x)
print("Example:")
print(
converter(
(
(0, 0, 1, 0, 0),
(0, 1, 0, 1, 0),
(1, 0, 2, 0, 1),
(0, 1, 0, 1, 0),
(0, 0, 1, 0, 0),
)
)
)
# These "asserts" are used for self-checking
assert (
converter(
(
(0, 0, 1, 0, 0),
(0, 1, 0, 1, 0),
(1, 0, 2, 0, 1),
(0, 1, 0, 1, 0),
(0, 0, 1, 0, 0),
)
)
== "cgikMoqsw"
)
assert (
converter(
(
(1, 0, 1, 0, 1),
(0, 2, 0, 2, 0),
(1, 0, 1, 0, 1),
(0, 2, 0, 2, 0),
(1, 0, 1, 0, 1),
)
)
== "aceGIkmoQSuwy"
)
print("The mission is done! Click 'Check Solution' to earn rewards!")
Feb. 10, 2024
Comments: