Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for String-2-Matrix by juestr
try:
# please upgrade to 3.12
from itertools import batched
except ImportError:
from itertools import islice
def batched(iterable, n):
it = iter(iterable)
while batch := tuple(islice(it, n)):
yield batch
def converter(text: str) -> tuple[tuple[int, ...], ...]:
textl = text.lower()
atoy = ((c in textl) + (c.upper() in text) for c in 'abcdefghijklmnopqrstuvwxy')
return tuple(batched(atoy, 5))
Feb. 8, 2024
Comments: