Skip to content

Hook12aaa/puzzle-solvers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PuzzleDojo

Solves all 7 LinkedIn daily puzzles, generates new ones, and reads screenshots so you don't have to type anything in.

Built as a React web app with Python solvers behind it. The interesting bits are the algorithms -- constraint propagation, exact cover, computer vision, Hamiltonian path generation. The less interesting bits are the glue code, but somebody had to write that too.

The Puzzles

Puzzle What's Going On Core Algorithm
Zip Connect numbered circles through every cell on a walled grid Constraint propagation + Tarjan's bridges + DFS
Queens N queens on an NxN colored-region board, no shared row/col/region Algorithm X (exact cover)
Tango Binary grid (Sun/Moon) with equality/inequality constraints Union-Find + constraint propagation
Sudoku 6x6 mini-Sudoku Row-permutation DFS with bitmask conflict detection
Patches Tile a grid with polyomino pieces, every cell covered once Algorithm X (exact cover)
Pinpoint 5 clue words, find the shared category WordNet hypernym intersection + TF-IDF
CrossClimb Crossword clues that form a word ladder BGE sentence embeddings + Hamiltonian path search

How It Works

Screenshot --> Vision Pipeline --> Board Model --> Constraint Engine --> Solver --> Solution

The vision pipeline runs in the browser via OpenCV.js WASM, so screenshots never leave the device. On the Python side it uses regular OpenCV. Both handle dark and light mode.

Each puzzle has its own board model, constraint engine, and solver. The board models are immutable-by-convention -- solvers return new instances rather than mutating state.

The Algorithms Worth Talking About

Zip was the hard one. The constraint engine runs an iterative fixed-point loop: parity validation, budget checks, bridge detection via Tarjan's, forced edge propagation, region assignment, bounds tightening. Each round can discover new forced/forbidden edges, so it loops until stable. After that, DFS cleans up whatever's left. The generator uses the backbite algorithm to produce random Hamiltonian paths, then iteratively places walls at solution divergence points until uniqueness is guaranteed.

Queens and Patches both reduce to exact cover problems. Algorithm X with dancing links handles these cleanly -- model the constraints as a binary matrix, let the algorithm find the exact cover.

Tango uses Union-Find to merge cells linked by equality constraints into equivalence classes. If an inequality constraint connects two cells in the same class, the puzzle is unsolvable. After that, standard constraint propagation (row/column balance, no-three-in-a-row) does most of the work.

CrossClimb was a fun one. It matches crossword clues to WordNet definitions using BAAI/bge-base-en-v1.5 sentence embeddings, then hybrid-scores with TF-IDF (60% semantic, 40% lexical). Once the words are identified, finding the ladder ordering is itself a Hamiltonian path search over a word-adjacency graph where edges connect words with Hamming distance 1.

Stack

Layer Tech
Solvers Python 3, NumPy, pandas, NLTK/WordNet, scikit-learn, Transformers
Web App React 19, Vite, Zustand
Vision OpenCV (Python), OpenCV.js WASM (browser)
GUI Pygame (local development)
Deployment Vercel (static frontend + Python serverless)

Quick Start

# Web app
cd app
npm install
npm run dev

# Python solvers
python scripts/zip_main.py                # Zip GUI (Space=new, Enter=solve, +/-=resize)
python scripts/zip_main.py screenshot.png  # Load a screenshot directly
python -m pytest                           # Run all tests

Project Layout

solvers/
  zip/           Board, constraints (Tarjan's, parity, regions), DFS search, vision, generator, GUI
  queens/        Board, Algorithm X exact cover, propagation solver, vision, generator
  tango/         Board, Union-Find constraints, vision, generator
  sudoku/        Board, bitmask row-permutation solver, vision, generator
  patches/       Board, Algorithm X exact cover, candidate generation, vision, generator
  pinpoint/      Hypernym solver, compound word detector
  crossclimb/    Clue solver (BGE + TF-IDF), word ladder search
scripts/         Entry points for each solver's GUI
tests/           500+ tests across all solvers and vision pipelines
app/
  src/
    puzzles/     Per-puzzle UI components and game hooks
    solvers/     Client-side JS solver implementations
    vision/      OpenCV.js screenshot readers
    components/  Shared UI
    stores/      Zustand state stores
  api/           Vercel serverless functions

Architecture details are in CLAUDE.md, which covers data flow, module internals, and the constraint propagation pipeline.

About

Solver, generator, and web app for 7 LinkedIn puzzle games. Constraint propagation, exact cover, Tarjan's bridges, backbite algorithm, OpenCV vision pipeline

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors