Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Overengineered solution in Clear category for Sequence Analyzer by veky
import itertools as I, string, operator
def letter_sequence(start, step):
alphabet = string.ascii_uppercase
position = alphabet.index(start)
while ...:
yield alphabet[position]
position += step
position %= len(alphabet)
def continuation(letters):
match letters:
case [letter]: return I.repeat(letter)
case [a, b, *_]:
generator = letter_sequence(a, ord(b) - ord(a))
if all(map(operator.eq, letters, generator)): return generator
def analyzer(input):
for intertwined in I.count(1):
further = [continuation(list(filter(None, sequence)))
for sequence in I.zip_longest(*I.batched(input, intertwined))]
if all(further):
keep_going = I.chain.from_iterable(zip(*further))
return ''.join(I.islice(keep_going, len(input)))
March 26, 2024