Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sudoku size could be variable to solve for example 4x4 or 16x16 sudokus #5

Closed
sfuhrm opened this issue Oct 30, 2022 · 6 comments
Closed

Comments

@sfuhrm
Copy link
Owner

sfuhrm commented Oct 30, 2022

It would also be nice if the size could be variable to solve for example 4x4 or 16x16 sudokus...

Originally posted by @Lemkinator in #4 (comment)

@sfuhrm sfuhrm changed the title It would also be nice if the size could be variable to solve for example 4x4 or 16x16 sudokus... Sudoku size could be variable to solve for example 4x4 or 16x16 sudokus Oct 30, 2022
@sfuhrm
Copy link
Owner Author

sfuhrm commented Nov 1, 2022

I've implemented variable sudoku sizes. Unfortunately 16x16 and 25x25 are really not working with the algorithm used here.

See:
https://github.com/sfuhrm/sudoku/releases/tag/sudoku-parent-4.0.0

@sfuhrm sfuhrm closed this as completed Nov 1, 2022
@Lemkinator
Copy link
Contributor

image

is that an copy paste error?

@Lemkinator
Copy link
Contributor

What does "the algorithm is really slow" mean, are there any numbers?

@sfuhrm
Copy link
Owner Author

sfuhrm commented Nov 2, 2022

Yes, you've found a C&P error in S25X25, thanks! This is fixed in 16ffe37

What does "the algorithm is really slow" mean, are there any numbers?

Creating full matrices is still quick, creating riddles isn't (text output doesn't make sense):

$ java -jar sudoku-client/target/sudoku-client-4.0.1-SNAPSHOT-jar-with-dependencies.jar -s S16X16 -e Full -t
16135261381297101141415
11871415141636529101213
91541237105131114162168
13261091112148154137165
81016971211121331461554
13131585261041297161114
51214641591317161182310
47211141016358156129131
14135166815411191210372
29101163712614131545811
12111571325101638414619
36841141197102513121516
71411251631412108151396
15413109671451113168212
61612131148159217514103
10598121314215166311147
Took total of 18ms
Each iteration took 18ms
$ java -jar sudoku-client/target/sudoku-client-4.0.1-SNAPSHOT-jar-with-dependencies.jar -s S16X16 -e Riddle -t
...

I never got a riddle of a 16x16 or 25x25 run. I think the backtracking approach is not suitable for that since the runtime can grow exponentially with the dimension growth of the game.

@Lemkinator
Copy link
Contributor

yep, but there is not really a performant alternative to backtracking, is there?
this app has 16x16 Sudokus and i wonder how they did... maybe just downloading pre-made sudokus/riddles?

@sfuhrm
Copy link
Owner Author

sfuhrm commented Nov 4, 2022

@Lemkinator
I have the suspect that the problem is the non deterministic loop in
https://github.com/sfuhrm/sudoku/blob/master/sudoku/src/main/java/de/sfuhrm/sudoku/Creator.java#L320
The proper way would be to do a backtracking search using a difficulty range as suggested in the articles mentioned above. A 'riddle has exactly one single solution' is expensive to calculate.
I did not yet have time to check it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants