Yanndroid / Sudoku

Android sudoku game and solver with OneUI design

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sudoku algorithm

opened this issue · comments

Which methods do you use for both the sudoku 4x4 and 9x9 algorithm and for the solver algorithm.?

commented

The "algorithms" are in de.dlyt.yanndroid.sudoku.game.Game.java (makeGameFromEdit() and generateFields()).
It's a recursive method to solve the sudoku by looping through all the fields and basically brute-forcing the solution.
Same goes for the generation, it puts random numbers in random fields, creates all the possible solutions for it, picks a random solution and then one by one removes a random number and checks if there's just one solution left.
I know this is probably the worst way to do this (and also the reason why 16x16 is impossible) but it initially only was a school project to solve sudokus.

commented

Sure np. I might use a library in the future that does that much faster but I haven't checked it out yet. Maybe it can also help you.