+
+
Bulgarian Solitaire
+
+ Choose a number n, then drag the {totalBoxes} boxes into columns.
+ Click "Play" to simulate the Bulgarian Solitaire process where one box is taken from each non-empty column to form a new column, continuing until reaching the triangular configuration (1, 2, 3, ..., n).
+
+
+
+ {/* Controls */}
+
+
+ n = {n}
+ setN(value[0])}
+ min={2}
+ max={6}
+ step={1}
+ className="w-32"
+ disabled={isPlaying}
+ />
+
+
+ Reset
+
+
+
+ {/* Container */}
+
+
+
Container
+
+ {containerBoxes.map((box) => (
+
handleDragStart(e, box.id)}
+ className="w-8 h-8 bg-primary rounded cursor-move hover:bg-primary/80 transition-colors flex items-center justify-center text-primary-foreground text-xs font-medium"
+ >
+ {box.id + 1}
+
+ ))}
+
+
+
+
+ {/* Columns */}
+
+
+
Columns
+ {step > 0 && (
+
Step: {step}
+ )}
+
+
+
+ {columns.map((column, index) => (
+
handleDrop(e, index)}
+ className="border border-muted-foreground rounded-lg min-h-[100px] p-2 bg-background/50 flex flex-col-reverse gap-1"
+ >
+
+ {index + 1}
+
+ {column.map((boxId, boxIndex) => (
+
handleDoubleClick(boxId)}
+ className="w-6 h-6 bg-primary rounded cursor-pointer hover:bg-primary/80 transition-colors flex items-center justify-center text-primary-foreground text-xs font-medium mx-auto"
+ title="Double-click to return to container"
+ >
+ {boxId + 1}
+
+ ))}
+
+ ))}
+
+
+
+ {/* Play Button */}
+
+ 0}
+ size="lg"
+ className="px-12"
+ >
+ {isPlaying ? 'Playing...' : 'Play'}
+
+
+
+ {/* Status */}
+ {isComplete && (
+
+
Triangular Configuration Reached! 🎉
+
+ The Bulgarian Solitaire process converged to the stable triangular configuration in {step} steps.
+
+
+ )}
+
+ {/* Instructions */}
+
+
How to Play:
+
+ Choose a value for n (2-6) using the slider
+ Drag the {totalBoxes} numbered boxes from the container into any of the columns
+ Double-click any box in a column to return it to the container
+ Once all boxes are placed in columns, click "Play" to start the simulation
+ Watch as the algorithm takes one box from each non-empty column to form a new column
+ The process continues until reaching the triangular configuration: columns of sizes 1, 2, 3, ..., n
+
+
+
+ {showSocialShare && (
+
+ )}
+
+ );
+};
+
+export default BulgarianSolitaire;
\ No newline at end of file
diff --git a/src/pages/BulgarianSolitairePage.tsx b/src/pages/BulgarianSolitairePage.tsx
new file mode 100644
index 0000000..2a9dfc6
--- /dev/null
+++ b/src/pages/BulgarianSolitairePage.tsx
@@ -0,0 +1,29 @@
+import BulgarianSolitaire from "@/components/BulgarianSolitaire";
+import { useSearchParams } from "react-router-dom";
+
+const BulgarianSolitairePage = () => {
+ const [searchParams] = useSearchParams();
+ const from = searchParams.get('from');
+
+ if (from === 'puzzles') {
+ return (
+