this post was submitted on 05 Jul 2023
9 points (100.0% liked)

commandline

1750 readers
1 users here now

founded 1 year ago
MODERATORS
 

cross-posted from: https://lemmy.world/post/1027203

cross-posted from: https://lemmy.world/post/961924

A script in bash in combination with a script in C can help you solve a sudoku puzzle in a png file.

https://gitlab.com/christosangel/sudoku-solver-ocr

You can see the script in action in this video.

The main dependency is tesseract OCR, responsible for the oprical character recognition.

Another important dependency is imagemagick, responsible for the necessary image manipulation.

The file selection of the png image is done with zenity.

Feel free to give your feedback.

top 2 comments
sorted by: hot top controversial new old
[โ€“] qwop 1 points 1 year ago (1 children)

Nice project! What approach to solving the sudoku did you use, is it a backtracking algorithm?

Having a look at the code it looks like there's quite a lot of repetition that could probably be refactored to be a bit cleaner!

[โ€“] [email protected] 1 points 1 year ago

Thank you!

The script is brute forcing its way through possible solutions of 3x3 squares,AND lines AND columns, util it finds a match (there can be moree than one).

The code is admittedly quite "dirty", lots of repetition and nested conditionals.

It was one of my first project in (self-taught) C, and it was a great lesson in pointers. It sure can be improved, in due time I suppose.

Again, thanks for the kind words and the feedback!