← Bank of America Interview Insights
I knew this was some kind of modular arithmetic thing the moment they said 7 prisoners and 7 colors, but getting from that intuition to an actual clean strategy took me longer than I'd like to admit.
Clarify the problem constraints (e.g., whether prisoners can communicate beforehand, if they must guess simultaneously, and if wrong guesses are allowed). Then, identify the core mathematical structure: this is a modular arithmetic problem where each prisoner computes a sum modulo 7 and uses a pre-agreed offset. Finally, present the strategy clearly, emphasizing that exactly one prisoner will guess correctly.
Pro tip: Demonstrate awareness of practical constraints: in a real system, communication and synchronization are costly, so the pre-agreed strategy must be simple and robust. Also, mention that this problem illustrates error-correcting codes and distributed consensus, which are relevant to banking systems.
Ask whether prisoners can agree on a strategy beforehand, whether they guess simultaneously, and whether wrong guesses have consequences. This ensures you understand the problem fully.
Assign each color a number 0–6. Each prisoner sees the sum of all other hats modulo 7. The goal is to ensure at least one prisoner guesses correctly.
Prisoners agree that prisoner i will guess that the total sum modulo 7 equals i. Then prisoner i computes their guess as (i - sum_of_others) mod 7. Exactly one prisoner will have the correct total sum, so exactly one will guess correctly.
Show that if the actual total sum modulo 7 is S, then prisoner S will guess correctly, and all others will guess wrong. Thus, at least one correct guess is guaranteed.
Mention that this strategy generalizes to n prisoners and n colors, and discuss trade-offs such as the need for pre-agreement and the fact that only one prisoner needs to be correct.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.