From 5d4d87b3a10662a7d7fe1b7c0f2bcb500619bc18 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Mon, 1 Dec 2025 07:06:42 +0000 Subject: [PATCH] Changes --- src/components/FerrersRogersRamanujan.tsx | 42 +++++++---------------- 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/src/components/FerrersRogersRamanujan.tsx b/src/components/FerrersRogersRamanujan.tsx index 8ba6cc3..9f44999 100644 --- a/src/components/FerrersRogersRamanujan.tsx +++ b/src/components/FerrersRogersRamanujan.tsx @@ -58,49 +58,31 @@ const FerrersRogersRamanujan = () => { setIsAnimating(true); }; - // Animation effect + // Animation effect - traverse main diagonal only useEffect(() => { if (!isAnimating || committedPartition.length === 0) return; const partition = committedPartition; - // Find the hook at current animation step - let found = false; - let hookCount = 0; - let targetRow = 0, targetCol = 0; + // Main diagonal: positions (0,0), (1,1), (2,2), ... while box exists + const row = animationStep; + const col = animationStep; - const maxRow = partition.length; - const maxCol = partition[0] || 0; - - for (let d = 0; d < maxRow + maxCol && !found; d++) { - for (let r = 0; r <= d; r++) { - const c = d - r; - if (r < partition.length && c < partition[r]) { - if (hookCount === animationStep) { - targetRow = r; - targetCol = c; - found = true; - break; - } - hookCount++; - } - } - } - - if (!found) { - // Animation complete + // Check if this diagonal position has a box + if (row >= partition.length || col >= partition[row]) { + // Animation complete - no more diagonal boxes setIsAnimating(false); setAnimatingHook(null); return; } - setAnimatingHook({ row: targetRow, col: targetCol }); + setAnimatingHook({ row, col }); - // Calculate hook size - const boxesRight = partition[targetRow] - targetCol - 1; + // Calculate hook size: boxes to the right + boxes below + 1 (the box itself) + const boxesRight = partition[row] - col - 1; let boxesBelow = 0; - for (let r = targetRow + 1; r < partition.length; r++) { - if (partition[r] > targetCol) { + for (let r = row + 1; r < partition.length; r++) { + if (partition[r] > col) { boxesBelow++; } else { break;