From 179e247f71f804139b8e1c9318ad6a6ac5811a47 Mon Sep 17 00:00:00 2001 From: Neeldhara Misra Date: Tue, 22 Jul 2025 11:08:21 +0530 Subject: [PATCH] Fix Zeckendorf game: add more Fibonacci numbers (up to 55) to ensure targets are reachable --- src/components/ZeckendorfGame.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/ZeckendorfGame.tsx b/src/components/ZeckendorfGame.tsx index 9fcf67e..439b0d0 100644 --- a/src/components/ZeckendorfGame.tsx +++ b/src/components/ZeckendorfGame.tsx @@ -4,8 +4,8 @@ import { Card, CardContent } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import SocialShare from '@/components/SocialShare'; -// First 8 Fibonacci numbers: 1, 1, 2, 3, 5, 8, 13, 21 -const FIBONACCI_NUMBERS = [21, 13, 8, 5, 3, 2, 1, 1]; +// First 10 Fibonacci numbers: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 +const FIBONACCI_NUMBERS = [55, 34, 21, 13, 8, 5, 3, 2, 1, 1]; interface ZeckendorfGameProps { showSocialShare?: boolean; @@ -13,7 +13,7 @@ interface ZeckendorfGameProps { const ZeckendorfGame: React.FC = ({ showSocialShare = true }) => { const [targetNumber, setTargetNumber] = useState(0); - const [flippedCards, setFlippedCards] = useState(new Array(8).fill(false)); + const [flippedCards, setFlippedCards] = useState(new Array(10).fill(false)); const [currentSum, setCurrentSum] = useState(0); const [timer, setTimer] = useState(0); const [isGameActive, setIsGameActive] = useState(false); @@ -39,7 +39,7 @@ const ZeckendorfGame: React.FC = ({ showSocialShare = true for (let i = 0; i < numTerms; i++) { let index; do { - index = Math.floor(Math.random() * 8); + index = Math.floor(Math.random() * 10); } while (usedIndices.has(index)); usedIndices.add(index); @@ -53,7 +53,7 @@ const ZeckendorfGame: React.FC = ({ showSocialShare = true const startNewGame = useCallback(() => { const newTarget = generateValidTarget(); setTargetNumber(newTarget); - setFlippedCards(new Array(8).fill(false)); + setFlippedCards(new Array(10).fill(false)); setCurrentSum(0); setTimer(0); setIsGameActive(true); @@ -135,7 +135,7 @@ const ZeckendorfGame: React.FC = ({ showSocialShare = true {/* Cards representing Fibonacci numbers */} -
+
{FIBONACCI_NUMBERS.map((fib, index) => (