Your question is Shuffling Names and Sorting Code. 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.
Sonata Software needs a reproducible way to rearrange names for test data and display them in alphabetical order. Given a list of names and a non-negative seed, implement a deterministic shuffle using the Fisher-Yates algorithm, then return both the shuffled list and a case-insensitive sorted copy.
Use this linear congruential generator for reproducibility:
state = (1103515245 * state + 12345) % 2^31
During Fisher-Yates, process indices from n - 1 down to 1. After updating the generator state, choose j = state % (i + 1) and swap positions i and j. The input list must not be modified. Sorting must be stable, so names that differ only by case retain their original relative order in the sorted result.
Implement shuffle_and_sort_names(names, seed). The input is a list of strings and a non-negative integer. Return a dictionary with shuffled, containing the deterministic permutation, and sorted, containing the original names sorted by name.casefold().
def shuffle_and_sort_names(names, seed):