Pregunta de entrevista de Jane Street

Optimization question - dice game (2 dices)