diff --git a/api/advent22_api/routers/_misc.py b/api/advent22_api/routers/_misc.py index 440ec28..3b402e8 100644 --- a/api/advent22_api/routers/_misc.py +++ b/api/advent22_api/routers/_misc.py @@ -12,10 +12,15 @@ async def get_loesungswort() -> str: async def set_length(seq: Sequence, length: int) -> list: + # `seq` unendlich wiederholen infinite = itertools.cycle(seq) + # Die ersten `length` einträge nehmen return list(itertools.islice(infinite, length)) async def shuffle(seq: Sequence) -> list: + # Zufallsgenerator rnd = random.Random(await get_loesungswort()) + + # Elemente mischen return rnd.sample(seq, len(seq))