Design a shuffle function (e.g., for a deck of cards)
Asked in the onsite_round_1 stage. The candidate noted they had seen a similar question at Amazon, received hints from the interviewer, and felt they answered poorly but got through.
Implement shuffle(items, random_values). Modify items in place and return it. The list contains arbitrary values. For deterministic testing, random_values contains n - 1 values in [0, 1), consumed while iterating from the final index down to index 1. At index i, choose j = int(random_values[k] * (i + 1)) and swap items[i] with items[j].
def shuffle(items, random_values):