adventOfCode/challenges/2022/06-tuningTrouble/py/__init__.py
AKP 5c61b3acfb
2022-06 py,nim & 2022-05 nim
Signed-off-by: AKP <tom@tdpain.net>
2022-12-06 09:43:49 +00:00

19 lines
503 B
Python

from typing import *
from aocpy import BaseChallenge
def find_unique_sequence(instr: str, length: int) -> int:
for i in range(len(instr) - length):
if len(set(instr[i : i + length])) == length:
return i + length
raise ValueError("cannot solve")
class Challenge(BaseChallenge):
@staticmethod
def one(instr: str) -> int:
return find_unique_sequence(instr, 4)
@staticmethod
def two(instr: str) -> int:
return find_unique_sequence(instr, 14)