In a previous post, I described a program I had created in Python to solve nonograms. That program could only reliably solve 4 x 4 boards, but it could occasionally get lucky on a 5 x 5. I wanted to do better than that and I’ve been meaning to dip my toes into Rust. So I made a similar solver in Rust.

Learning Rust

Rust has been a joy to learn. Some of the highlights have been

  • amazing error messages and suggested fixes
  • ownership system thing that’s like pointers but actually works
  • straightforward package manager
    • keep in mind that I’m coming from a background of Python, R, and C—almost any package manager blows me away
  • cargo run instead of gcc solver.c -o solver && ./solver, or worse
  • pretty good type inference
  • execution speed

I did encounter some trouble when I tried to compare the Rust script to the Python script by profiling the code. I developed the Rust script using WSL 2, which doesn’t support perf (as far as I can tell). The Rust profilers I found were based on perf, so I couldn’t profile the code.

Can it solve 5 x 5 boards?

Yes! It can even solve 6 x 6 boards in only a second or two. 7 x 7 seems to be about the limit of what it can do in a reasonable amount of time. It takes circa 200–400 seconds for it to solve a 7 x 7 board.