sudoku

64 views
Skip to first unread message

fbogd...@xnet.hr

unread,
Oct 24, 2011, 3:07:19 PM10/24/11
to Screamer
Hi.

I would like to create a sudoku table.
How do I do it in Sceamer ?
Is there some finished example maybe ?

Thanks

Nikodemus Siivola

unread,
Oct 25, 2011, 8:08:47 AM10/25/11
to scre...@googlegroups.com

No sudoku examples, sorry -- and the existing examples are probably
more help if you want to /solve/ sukodus.

I haven't ever really thought about what kind of decisions are
involved in generating a sudoku board, so I can't bang out a sketch
either. (I'm not even sure if Screamer is a good match for the
problem, actually. It's definitely a good match for /solving/ a board,
but less sure about generating one.)

Cheers.

-- nikodemus

sfr...@cs.tu-berlin.de

unread,
Oct 25, 2011, 9:26:57 AM10/25/11
to scre...@googlegroups.com
Hi,

just to add my two cents: as far as I know there is no structural approach
to generate Sudoku puzzles. Maybe the following is a viable way:

- start with a fully filled board and randomly shuffle the columns and rows
- now randomly remove some numbers
- check that the resulting problem is still a Sudoku, i.e. it has a unique
solution
- start again and maybe remove some more values

Since in the last step you may search over a very huge search space you
wan to
- set a time limit for the solving process
- maybe limit the number of fails to avoid creating overly difficult
problems.

With the provided Sudoku solver example I _think_ you can realize the
above approach without much difficulty (talk is cheap, I know). Though, I
don't know off hand whether Screamer allows for a time based search limit.

Best regards,
Stephan

sfr...@cs.tu-berlin.de

unread,
Oct 25, 2011, 9:53:47 AM10/25/11
to scre...@googlegroups.com
And perhaps I should amend the the shuffling in the first step has
obvioulsly to happen within the 3-row/colum Sub-Block, so it is
effectivly:

1. randomly select a row or column and shuffle the three rows/columns of
its Sub-Block
2. goto 1. until you think it's been enough shuffling
3. proceed with the steps below

Haris Bogdanovich

unread,
Oct 25, 2011, 12:57:22 PM10/25/11
to scre...@googlegroups.com
Does that mean that Screamer isn't for constraint programming ?
I saw in Ruby simple example of creating sudoku with gecodw library.
What is then library for constraint programmiing in Lisp ?

Haris Bogdanovich

unread,
Oct 25, 2011, 1:09:11 PM10/25/11
to scre...@googlegroups.com
> Does that mean that Screamer isn't for constraint programming ?
> I saw in Ruby simple example of creating sudoku with gecodw library.

Sorry, I meant Gecode library.

Stephan Frank

unread,
Oct 25, 2011, 1:18:42 PM10/25/11
to scre...@googlegroups.com

Hi Haris,

I have the feeling that we are misunderstanding each other. What I
described was a solution for creating Sudoku puzzles with the help of
the already existing constraint solving based solver which checks that
you didn't remove too many fields such that there is more than one solution.

I know of no other way where constraints would be of further help when
one is _generating_ Sudoku puzzles other than checking that there is a
unique solution.

Could you point me to the Ruby could you mentioned?

Kind regards,
Stephan

Haris Bogdanovich

unread,
Oct 25, 2011, 4:49:21 PM10/25/11
to scre...@googlegroups.com
> Could you point me to the Ruby could you mentioned?

http://gecoder.rubyforge.org/examples/sudoku.html

I don't really know much about constraint programming,
is that just the way I create an algorithm
or I need some library for that ?

Stephan Frank

unread,
Oct 25, 2011, 7:43:24 PM10/25/11
to scre...@googlegroups.com

Hi Haris,

this is a Sudoku solver, not a Sudoku problem generator.

But I have to apologize: some time ago I discussed some additional
Screamer examples with Nikodemus and one such example included a Sudoku
solver. Somehow this hasn't made it into the repository yet, so my
reference to the examples directory was misleading. Please find attached
the example which should run with the Screamer code of the dev branch
from github.

Best regards and sorry for the confusion,
Stephan

sudoku.lisp

Nikodemus Siivola

unread,
Oct 26, 2011, 7:15:06 AM10/26/11
to scre...@googlegroups.com
On 26 October 2011 02:43, Stephan Frank <sfr...@cs.tu-berlin.de> wrote:

> solver. Somehow this hasn't made it into the repository yet, so my
> reference to the examples directory was misleading. Please find attached
> the example which should run with the Screamer code of the dev branch
> from github.

This totally fell off my map. I'll try to see to it this week.

Many thanks for the example!

Cheers,

-- nikodemus

Nikodemus Siivola

unread,
Oct 31, 2011, 7:51:57 AM10/31/11
to scre...@googlegroups.com
On 26 October 2011 14:15, Nikodemus Siivola <niko...@sb-studio.net> wrote:

>> solver. Somehow this hasn't made it into the repository yet, so my
>> reference to the examples directory was misleading. Please find attached
>> the example which should run with the Screamer code of the dev branch
>> from github.
>
> This totally fell off my map. I'll try to see to it this week.

Now in documentation.

Apropos: I added a branch "wip" which has cleaner history than "dev",
and should be functionally equivalent -- but unlike "dev" it will be
rebased periodically.

Once the batting list for 3.21 is complete, "master" will become
"classic" and "wip" will become "master", and "dev"... will be
forgotten. (So "dev" is just a convenience for now to make pulling it
easy.)

Cheers,

-- nikodemus

Reply all
Reply to author
Forward
0 new messages