Your question is Shuffle Deck Algorithm. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Intelligent Medical Objects may use randomized card-style test data when validating terminology workflows. Given a list representing a deck, implement an in-place shuffle so every possible ordering is equally likely.
Use the Fisher-Yates algorithm. The function must modify the input list and return it. For deterministic testing, accept an optional seed and use Python's random.Random(seed) as the random number generator. If seed is None, use nondeterministic randomness.
Implement shuffle_deck(deck, seed), where deck is a mutable list of distinct or repeated values and seed is either an integer or None. Return the same list object after shuffling it in place. The output must contain exactly the same values and frequencies as the input.
With a fixed seed, the result must be reproducible. Without a fixed seed, every permutation should have equal probability.
def shuffle_deck(deck, seed):