mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-12-26 06:03:01 +00:00
20 lines
502 B
Python
20 lines
502 B
Python
|
import random
|
||
|
from typing import Any, Self, Sequence
|
||
|
|
||
|
from ..config import get_config
|
||
|
|
||
|
|
||
|
class Random(random.Random):
|
||
|
@classmethod
|
||
|
async def get(cls, bonus_salt: Any = "") -> Self:
|
||
|
cfg = await get_config()
|
||
|
return cls(f"{cfg.puzzle.solution}{bonus_salt}{cfg.puzzle.random_pepper}")
|
||
|
|
||
|
|
||
|
async def shuffle(seq: Sequence, rnd: random.Random | None = None) -> list:
|
||
|
# Zufallsgenerator
|
||
|
rnd = rnd or await Random.get()
|
||
|
|
||
|
# Elemente mischen
|
||
|
return rnd.sample(seq, len(seq))
|