A modern web-based collection of three classic logic puzzles with AI-assisted building capabilities. Built with vanilla JavaScript and featuring a sleek dark gaming theme.
Objective: Place queens on a grid so that no two queens attack each other, with each colored region containing exactly one queen.
Rules:
- Grid is divided into numbered colored regions (1-11)
- Each region must contain exactly one queen
- No two queens can be on the same row, column, or diagonal
- Queens cannot attack each other
Objective: Fill the grid with sun (☀) and moon (☾) symbols following constraint rules.
Rules:
- Each cell contains either a sun or moon symbol
- Adjacent cells can have equality (=) or difference (×) constraints
- No more than 2 consecutive identical symbols in any row/column
- Each row and column must have exactly half suns and half moons
Objective: Connect numbered dots in sequence with a continuous path.
Rules:
- Numbered dots are placed on the grid starting with 1
- Draw a path connecting all dots in numerical order (1→2→3→...)
- Walls (thick borders) block movement between adjacent cells
- Path must visit every numbered dot exactly once
- Path can only move horizontally or vertically (no diagonal moves)
Each puzzle includes an AI-assisted building mode powered by Google's Gemini API:
- Screenshot Analysis: Upload or paste puzzle images for automatic recognition
- Smart Prompt Generation: Contextual prompts optimized for each puzzle type
- JSON Output: Structured data format for precise puzzle recreation
- Manual Editing: Fine-tune AI results with interactive editing tools
- Select Grid Size: Choose puzzle dimensions (2x2 to 11x11)
- Upload Image: Paste screenshot or upload puzzle image
- Generate Prompt: AI creates optimized recognition prompt
- Run AI: Gemini analyzes image and returns structured JSON
- Apply & Edit: Load results and manually adjust if needed
ALGORITHM: Recursive Backtracking
1. Place queens row by row (one queen per row)
2. For each row, try each column position
3. Check constraints:
- No column conflicts (only one queen per column)
- No diagonal conflicts (|r1-r2| ≠ |c1-c2|)
- Region constraints (one queen per colored region)
4. If valid placement, recurse to next row
5. If no valid placement, backtrack and try next position
TIME COMPLEXITY: O(N!) in worst case, but pruning makes it much faster
SPACE COMPLEXITY: O(N) for recursion stack
ALGORITHM: Backtracking with Constraint Validation
1. Fill cells one by one with sun (1) or moon (0)
2. For each cell, try both values
3. Check constraints after each placement:
- Row/column balance (exactly N/2 suns and moons)
- No more than 2 consecutive identical symbols
- Equality constraints (= edges must have same values)
- Difference constraints (× edges must have different values)
4. If constraints violated, backtrack
5. If all cells filled successfully, solution found
TIME COMPLEXITY: O(2^N) worst case, pruned by constraint checking
SPACE COMPLEXITY: O(N²) for grid state
ALGORITHM: DFS with Path Validation
1. Start from dot #1, maintain current path
2. For each position, try all 4 directions (up/down/left/right)
3. Check movement validity:
- No walls blocking the path
- Stay within grid boundaries
- Don't revisit cells (except for backtracking)
4. When reaching next numbered dot, continue from that position
5. Solution found when all dots connected in sequence
TIME COMPLEXITY: O(4^(N²)) worst case, pruned by wall constraints
SPACE COMPLEXITY: O(N²) for visited tracking and path storage
- Modern web browser with JavaScript enabled
- Gemini API key (for AI features)
-
Clone the repository:
git clone https://github.com/lookasdev/linkedin-puzzles.git cd linkedin-puzzles -
Open
index.htmlin your web browser or go to https://linkle-demo.netlify.app/ -
(Optional) Set up Gemini API key:
- Get API key from Google AI Studio
- Enter key in the main page - it will be saved locally
- Key persists across all puzzle sessions
- Select a Puzzle: Choose from Queens, Tango, or Zip
- Solve Mode: Use existing puzzles with the built-in solver
- Build Mode: Create new puzzles manually or with AI assistance
- AI Mode: Upload puzzle images for automatic recognition
linkedin-puzzles/
├── index.html # Main entry point with puzzle selection
├── styles.css # Unified dark gaming theme
├── queens.html # Queens puzzle interface
├── queens.js # Queens puzzle logic & solver
├── tango.html # Tango puzzle interface
├── tango.js # Tango puzzle logic & solver
├── zip.html # Zip puzzle interface
├── zip.js # Zip puzzle logic & solver
└── README.md # This file
Enjoy solving and building puzzles! 🧩✨