Shuffle All the Decks
Reported by candidates from Bloomberg's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Bloomberg's 'Shuffle All the Decks' is a permutation or simulation problem that shows up when they want to see if you can model state change correctly under repeated operations. You're likely shuffling multiple decks and tracking their final state, which means the trick is figuring out the periodicity or the pattern of the shuffle itself rather than brute-forcing all iterations. If you blank on the math during the OA, StealthCoder can read the problem and surface the shuffle algorithm pattern in seconds.
Pattern and pitfall
The core challenge is recognizing whether you're dealing with a deterministic shuffle (like a riffle shuffle or a specific permutation cycle) where you need to find the order, or a simulation problem where you track deck states through multiple operations. Most candidates overthink the implementation and miss that shuffles often have a cycle length you can exploit with modular arithmetic. The trap is simulating every single shuffle step when the answer lives in the cycle detection or the mathematical period. StealthCoder's real value here is flagging which approach fits the constraints the moment you see the problem statement live.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Shuffle All the Decks cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Bloomberg's OA.
Bloomberg reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Shuffle All the Decks FAQ
Is this asking me to implement a real shuffle algorithm or just model the permutation?+
Most likely you're modeling a specific permutation cycle. Real shuffle algorithms (riffle, etc.) are deterministic. The problem probably gives you the shuffle pattern and asks for the final state after N shuffles. Focus on cycle detection, not card-by-card simulation.
What's the trick if there are multiple decks?+
Multiple decks usually means you apply the same permutation to each deck independently, or you're tracking positions across a single logical deck. Either way, the cycle length of the permutation is your key. Find it once, use modulo to skip iterations.
How do I even start if the problem statement is vague?+
Assume a small example. Shuffle 2-3 cards a few times by hand. Write down the state after each shuffle. Look for repetition. That repetition is your cycle. Once you see it, the algorithm is trivial.
Is there a mathematical shortcut or do I have to simulate?+
Yes. Find the cycle length of the permutation. If a deck returns to its original state after K shuffles, then N shuffles is equivalent to N % K shuffles. This saves you from timeout on large N.
How much time should I spend on this in a real OA?+
15-20 minutes to understand the shuffle pattern and code cycle detection. Don't get stuck on corner cases like single-card or empty-deck edge cases unless the problem explicitly mentions them.