Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
one liner solution in Creative category for Matrix-2-String by tamagoyaki
Row = tuple[int, int, int, int, int]
Grid = tuple[Row, Row, Row, Row, Row]
def converter(matrix: Grid) -> str:
return "".join([chr(i*5+j+129-32*c) for i,m in enumerate(matrix) for j,c in enumerate(m) if c != 0])
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!")
March 5, 2024
Comments: