From d0ef67e995d5cdf6b90893bf289452c07af6f9b5 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Wed, 19 Nov 2025 03:56:52 +0000 Subject: [PATCH] Changes --- src/components/PresentsPuzzle.tsx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/components/PresentsPuzzle.tsx b/src/components/PresentsPuzzle.tsx index fe945da..b465e21 100644 --- a/src/components/PresentsPuzzle.tsx +++ b/src/components/PresentsPuzzle.tsx @@ -273,7 +273,26 @@ const PresentsPuzzle = ({ }; 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 = () => {