Changes
This commit is contained in:
parent
6450824c73
commit
d0ef67e995
1 changed files with 20 additions and 1 deletions
|
|
@ -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 = () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue