Co-authored-by: Mikael CAPELLE <mikael.capelle@thalesaleniaspace.com> Co-authored-by: Mikaël Capelle <capelle.mikael@gmail.com> Reviewed-on: #3
17 lines
421 B
Python
17 lines
421 B
Python
from typing import Any, Iterator
|
|
|
|
from ..base import BaseSolver
|
|
|
|
|
|
def index_of_first_n_differents(data: str, n: int) -> int:
|
|
for i in range(len(data)):
|
|
if len(set(data[i : i + n])) == n:
|
|
return i + n
|
|
return -1
|
|
|
|
|
|
class Solver(BaseSolver):
|
|
def solve(self, input: str) -> Iterator[Any]:
|
|
yield index_of_first_n_differents(input, 4)
|
|
yield index_of_first_n_differents(input, 14)
|