473,549 Members | 2,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Looking for really hard sudoku puzzles

jkmyoung
2,057 Recognized Expert Top Contributor
Does anyone have some super, super hard Sudoku puzzles?

Back in February this year, I had enough time to finally program a Sudoku solver in Java. Right now, I'm looking for solvable puzzles, but ones that my program cannot solve. However, most hard puzzles in the newspapers are solved within 2-3 cycles so far.

The ones I've found on google which are said to be hard, get solved in 3 cycles.

Any help would be very much appreciated!
=============== =============== ==========
The program works on the possible values for each cell.
1. Determine the possible values in each cell.
2. Check rows. If there is any value in which only 1 empty cell can take that value, set empty cell to that value.
3. Columns.
4. Nonets, (3X3 Squares.)
5. Indiviual cells.
Dec 17 '08 #1
62 12146
Nepomuk
3,112 Recognized Expert Specialist
Well, I have some on my mobile which that solver might not be able to solve, so here are a few:
Expand|Select|Wrap|Line Numbers
  1. |xx1|xxx|xxx|
  2. |x2x|345|xxx|
  3. |xxx|xxx|267|
  4.  
  5. |x4x|x6x|xxx|
  6. |87x|xxx|x51|
  7. |xxx|x1x|x9x|
  8.  
  9. |563|xxx|xxx|
  10. |xxx|927|xxx|
  11. |xxx|xxx|8xx|
  12.  
Expand|Select|Wrap|Line Numbers
  1. |x1x|x2x|3xx|
  2. |x2x|4xx|xxx|
  3. |x3x|5xx|6xx|
  4.  
  5. |3xx|x7x|xx1|
  6. |8xx|xxx|xx9|
  7. |4xx|x6x|xx5|
  8.  
  9. |xx9|xx1|x8x|
  10. |xxx|xx2|x5x|
  11. |xx7|x3x|x4x|
  12.  
Expand|Select|Wrap|Line Numbers
  1. |xxx|x1x|xx2|
  2. |3xx|4xx|x5x|
  3. |6xx|7xx|x8x|
  4.  
  5. |xx1|x5x|9xx|
  6. |xx4|xxx|2xx|
  7. |xx5|x6x|7xx|
  8.  
  9. |x5x|xx8|xx6|
  10. |x7x|xx2|xx3|
  11. |9xx|x4x|xxx|
  12.  
("x" being an empty field) Hope that helps.

Greetings,
Nepomuk
Dec 17 '08 #2
JosAH
11,448 Recognized Expert MVP
Thanks for those puzzles; I just checked: my old solver solves them all instantaneously . (see that old article about Sudoku).

kind regards,

Jos

ps. solving took 14, 2 and 9 ms respectively but that includes the class loading etc. Those are highly inaccurate timings.
Dec 17 '08 #3
jkmyoung
2,057 Recognized Expert Top Contributor
Managed to find a bug in the program thanks to your inputs. After running those 3 problems through again, I got.
1. Solved. 5 cycles.
2. Not enough data, or unsolvable puzzle.
3. Not enough data, or unsolvable puzzle.

Will have to look up ways to refine the algorithm, so that it can solve the last 2.
Dec 17 '08 #4
JosAH
11,448 Recognized Expert MVP
@jkmyoung: can you tell a bit about your algorithm? The solver I wrote just uses a brute force search and a bit of local cleverness to quickly determine whether or not a value in a cell is possible. Basically it can't go any faster than it goes without any 'intelligence'.

kind regards,

Jos

ps. what's a 'cycle' in your algorithm?
Dec 17 '08 #5
jkmyoung
2,057 Recognized Expert Top Contributor
Each cell has an integer associated with it, representing the possible combinations for that square. Each cell uses 10 bits.
1<<0 Lowest order bit, determines if the value is finalized.
1<<1 bit determines if 1 is possible,
1<<2 bit determines if 2 is possible,
etc..

We also have 3 X 9 integers for the rows, cols, and nonets for the numbers that are already set.

After the numbers are loaded, we loop through the following process.
Main loop:
Side Loop1: Check rows.
Examine the 9 numbers in the current row. If there are any values such that only 1 cell can have them, and they aren't set yet, then set them. If there is no possible cell for a value, throw an error.

Side Loop2: Check cols,
Side Loop3: Check nonets,
Side Loop4: Check each individual cell.
If a cell has only one possible value and isn't set yet, then mark it as set.

End Main loop

A 'cycle' is one iteration through the main loop.
Dec 19 '08 #6
JosAH
11,448 Recognized Expert MVP
I don't understand how your algorithm 'starts up'. Suppose there's an empty Sudoku puzzle: every row/column/sub-square/cell can store one of nine values so none is assigned in your cycle ...

kind regards,

Jos
Dec 20 '08 #7
jkmyoung
2,057 Recognized Expert Top Contributor
Ah sorry, didn't think it made a difference.

Loading:
The program only reads in 81 digits, from 0-9. 0 is an empty space, 1-9 are set numbers. It ignores all other input. It determines if there are any duplicate numbers in any row/column/nonet, and if so throws an "InvalidInp ut" error.

Running:
If no changes are made within a single cycle, then the program returns:
Not enough data, or unsolvable puzzle.

Side Loop4: Check each individual cell. If there is no possible value for a cell, the program throws an error stating something like "No possible value for cell (x,y)"

===============
So if you have an empty puzzle, no changes will be made in a cycle.
- Program returns "Not enough data, or unsolvable puzzle."

===============
If you have an impossible puzzle like
Expand|Select|Wrap|Line Numbers
  1. -23------
  2. 456------
  3. 789------
  4. ---------
  5. ---------
  6. ---------
  7. ---------
  8. ---------
  9. 1--------
  10.  
The puzzle will return:
"No possible value for cell (1,1)"
Dec 22 '08 #8
JosAH
11,448 Recognized Expert MVP
@jkmyoung
Ah, ok; so your algorithm completes a partially filled board if only one solution is possible, i.e. it doesn't find any or all possible solutions given a partial solution, right?

kind regards,

Jos
Dec 22 '08 #9
jkmyoung
2,057 Recognized Expert Top Contributor
Yes. Have thought about it, but haven't figured out a way beyond brute force, so haven't implemented it yet.
Dec 23 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2629
by: sub1ime_uk | last post by:
Thought I'd offer a method for solving all possible 9x9 sudoku puzzles in one go. It'll takes a bit of time to run however (and 9x9 seems to be about as big as is reasonably possible before combinatorial explosion completely scuppers this type of program)... Basic idea:- Start with a grid initialised with: 123456789
5
9969
by: Stewart Gordon | last post by:
I have a few Sudoku puzzles on my site. http://www.stewartsplace.org.uk/mindbenders/ But adding extra columns and rows to separate the 3x3 blocks seems a rather kludgy approach, and the result isn't aesthetically the best either. There ought to be a way of making the grids look nicer. I've played about a bit with rowgroups and...
12
6323
by: kalinga1234 | last post by:
hy guys i am having a problem with my sudoku program which i coded using c++.; currently in my program if a duplicate number exist in either row/column/block i would make the particualr square 0. but thats not i want to do. I want to recurse back until until it find a correct number. i will post the function which i need the help; ...
4
1777
by: hashimtk | last post by:
Hi, i done a sudoku solving program ,and i got solution for easy sudoku, Can u explain any logic to find out medium and hard sudoku.
10
1627
by: doubleac | last post by:
Hi This is the first time for me asking for help in forums on the net. I hope ill make myself understood. And sorry for my bad english. I have 4 classes: Spelare, Händelser, SpelPlan and Start. In the class "Händelser" a random message apperas, if the players land on a couple of specific squares. A message is supposed to change the...
38
6344
by: Boon | last post by:
Hello group, I've been toying with a simple sudoku solver. I meant for the code to be short and easy to understand. I figured "brute force is simple" -- who needs finesse, when you've got muscle, right? :-) http://en.wikipedia.org/wiki/Sudoku Thus, the strategy is to test every legal "move" and to backtrack when stuck. A recursive...
3
2858
jkmyoung
by: jkmyoung | last post by:
Hey, are there any sudoku experts out there? Can anyone tell me the next step in solving this sudoku and explain it properly? I've used all the rules I can think of but am now stuck. 51--263-- 7264-35-8 93-5-76-- 395278461 86--54--9 47--698-5 -59-41-83 -43--2-5-
3
3381
by: Ri0o | last post by:
hi, i have to make a sudoku solver using python quickdraw, i've started on it and this is what i got so far here is the link to the assignment http://pages.cpsc.ucalgary.ca/~zongpeng/CPSC231/assignments/A4/a4.pdf def solveRows(): """eliminates solved numbers by row""" for x in range(0, 81, 9): row = puzzle#loops through each...
1
2789
by: 361162 | last post by:
Sudoku puzzles are made up of the numbers 1-9 arranged in a 9by9 grid, where every number must appear exactly once in every column, row and 3by3 block in order for the solution to be valid. Sudoku puzzles are often given as competition in newspapers. Your job is to write a sudoku checker that will check if sudoku solution is valid or not. Input...
0
7520
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7450
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7720
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1059
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.