This commit is contained in:
gpt-engineer-app[bot] 2025-11-19 03:56:52 +00:00
parent 6450824c73
commit d0ef67e995

View file

@ -273,7 +273,26 @@ const PresentsPuzzle = ({
}; };
const stepToEnd = () => { const stepToEnd = () => {
updateStep(99); const { presents, aliceOrder: aOrder, bobOrder: bOrder } = initializeSimulation();
let aliceCount = 0;
let bobCount = 0;
let winningStep = 99; // default to last step if no winner found
// Find the step where someone first wins
for (let i = 0; i < 100; i++) {
if (presents.has(aOrder[i])) aliceCount++;
if (presents.has(bOrder[i])) bobCount++;
// Check if someone won on this step
if (aliceCount === 26 || bobCount === 26) {
winningStep = i;
break;
}
}
// Update to that step
updateStep(winningStep);
}; };
const stepToStart = () => { const stepToStart = () => {