Skip to content

0xQQa/nonogram_solver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nonogram Solver

A fast and flexible Nonogram (Picross) puzzle solver written in Rust.

🚀 Features

  • Parses Nonogram clues from file input
  • Efficient solving of puzzles using logic-based strategies
  • Modular design with a reusable lib.rs
  • Command-line interface for puzzle loading and solving
  • Supports puzzles up to 64×64 in size

🛠 Usage

🔧 Test

cargo test -- --nocapture

📦 Build

cargo build --release

▶️ Run

cargo run -- tests/input_files/big_nonogram.txt

Example output:

Round: 1 ...
Round: 2 ...
Round: 3 ...
Round: 4 ...
Round: 5 ...
Round: 6 ...
Round: 7 ...
Round: 8 ...
Round: 9 ...
Resolving took 9 rounds in 2.4242ms!
  ■■■    ■■
 ■  ■   ■  ■
■  ■■  ■   ■■
■ ■■   ■  ■ ■■■
■ ■     ■■    ■
■■ ■■■   ■   ■■
 ■■■■■■■■■ ■■■
 ■■      ■■■
 ■        ■■
 ■  ■  ■   ■
 ■  ■■■■   ■
■  ■■  ■■  ■■
■ ■  ■ ■ ■ ■ ■■
■■ ■ ■  ■■  ■ ■
 ■■■ ■■■■ ■■■ ■

📄 Input Format

The puzzle file should contain two lines:

  • First line: Vertical clues as Vec<Vec>
  • Second line: Horizontal clues as Vec<Vec>

Where big_nonogram.txt looks like:

[4,3],[1,6,2],[1,2,2,1,1],[1,2,2,1,2],[3,2,3],[2,1,3],[1,1,1],[2,1,4,1],[1,1,1,1,2],[1,4,2],[1,1,2,1],[2,7,1],[2,1,1,2],[1,2,1],[3,3]
[3,2],[1,1,1,1],[1,2,1,2],[1,2,1,1,3],[1,1,2,1],[2,3,1,2],[9,3],[2,3],[1,2],[1,1,1,1],[1,4,1],[1,2,2,2],[1,1,1,1,1,1,2],[2,1,1,2,1,1],[3,4,3,1]

Or as vectors:

    let solving_vector_vertical: Vec<Vec<u8>> = vec![
        vec![4, 3],
        vec![1, 6, 2],
        vec![1, 2, 2, 1, 1],
        vec![1, 2, 2, 1, 2],
        vec![3, 2, 3],
        vec![2, 1, 3],
        vec![1, 1, 1],
        vec![2, 1, 4, 1],
        vec![1, 1, 1, 1, 2],
        vec![1, 4, 2],
        vec![1, 1, 2, 1],
        vec![2, 7, 1],
        vec![2, 1, 1, 2],
        vec![1, 2, 1],
        vec![3, 3],
    ];

    let solving_vector_horizontal: Vec<Vec<u8>> = vec![
        vec![3, 2],
        vec![1, 1, 1, 1],
        vec![1, 2, 1, 2],
        vec![1, 2, 1, 1, 3],
        vec![1, 1, 2, 1],
        vec![2, 3, 1, 2],
        vec![9, 3],
        vec![2, 3],
        vec![1, 2],
        vec![1, 1, 1, 1],
        vec![1, 4, 1],
        vec![1, 2, 2, 2],
        vec![1, 1, 1, 1, 1, 1, 2],
        vec![2, 1, 1, 2, 1, 1],
        vec![3, 4, 3, 1],
    ];

📦 Dependencies

No external crates (100% safe Rust)

Contributing

Pull requests are welcome. Fell free to report a bug.

License

CC BY-NC-SA

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages