| Crates.io | qsolve |
| lib.rs | qsolve |
| version | 1.0.0 |
| created_at | 2025-04-23 22:21:51.659389+00 |
| updated_at | 2025-04-23 22:21:51.659389+00 |
| description | A command-line tool for solving Queens puzzles |
| homepage | |
| repository | https://github.com/dschafer/qsolve |
| max_upload_size | |
| id | 1646403 |
| size | 177,614 |
A command line tool and library for solving Queens puzzles

This command line tool and library is designed to solve Queens puzzles, with a few key characteristics:
cargo test passes, then we should be confident things work.qsolve binary should have clear documentation available with --help for every subcommand. The qsolve library should have clear documentation (including doctests) for all public functionality.qsolve can be installed from crates.io by running
cargo install qsolve
Alternately, the binary can be downloaded directly from Github releases.
Basic usage of the command line tool looks something like this:
qsolve solve games/linkedin-1-empty.txt --share
which yields the following screenshot (throughout this README, screenshots will be used since the command line tool relies heavily on ANSI color strings to output Queens boards):

More compelling, though, is the animate subcommand, which doesn't just solve the puzzle, but walks you through the solution step by step.
https://github.com/user-attachments/assets/6b4d6798-63be-4000-b850-c8a45008dd1d
Basic usage of the library looks something like this:
use std::path::PathBuf;
use qsolve::heuristic::all_heuristics;
use qsolve::file::QueensFile;
use qsolve::solveiter::solve_iter;
use qsolve::solvestate::{SolveState, SolveStrategy};
fn solve() -> Result<(), Box<dyn std::error::Error>> {
// Parse a text file containing a Queens puzzle.
let queens_file = QueensFile::try_from_text_file(&PathBuf::from("games/linkedin-1-empty.txt"))?;
// Generate the initial solve state and print it.
let solve_state = SolveState::from(&queens_file);
println!("{}", solve_state);
// Generate the list of heuristics to use to solve the puzzle.
let heuristics = all_heuristics(solve_state.board);
// Solve the puzzle and print out the solution.
let solved = solve_iter(solve_state, SolveStrategy::Fast, &heuristics).last().unwrap().solve_state;
println!("{}", solved);
Ok(())
}
qsolve is a side project, so development will happen in a pretty ad-hoc basis (and issues and PRs might go unanswered: caveat emptor). However, if you wish to fork or contribute back, here's a quick runthrough:
This repository contains both qsolve the binary and qsolve the library it depends on. The only logic in the binary is command line logic; all actual functionality should live in the library.
There are moderately comprehensive integration, unit and doctests that can be run with cargo test. Additionally, there are a few benchmarks using the criterion benchmark engine that can be run with cargo bench. In general, changes should be neutral or positive
in that benchmark (for example, a change to use the bitvec package to implement the data structures in src/datastructure.rs was abandoned because cargo bench showed it was a regression).