From 3bee806262014486b175caadd09e795cef9f656a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Fri, 14 Oct 2022 23:20:35 +0000 Subject: [PATCH] doc --- api/advent22_api/routers/_misc.py | 5 +++++ 1 file changed, 5 insertions(+) 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))