[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Sodoku-Generator

Meino Christian Cramer

2/19/2006 7:08:00 PM

6 Answers

M. Edward (Ed) Borasky

2/19/2006 7:49:00 PM

0

From the R library package "sudoku":

generateSudoku package:sudoku R Documentation

Randomly Generate a Sudoku Puzzle Grid

Description:

Creates a 9x9 Sudoku grid suitable for use by 'playSudoku'.

Usage:

generateSudoku(Nblank=50, print.it=FALSE)

Arguments:

Nblank: Number of cells to blank out

print.it: Logical. If true, print result to screen.

Details:

The basic algorithm is to start with a 'primordial' Sudoku grid,
swap around some rows and columns, then blank out some cells.

Value:

A matrix, representing a 9x9 Sudoku grid.

Author(s):

Curt Seeliger <Seeliger.Curt@epamail.epa.gov>, Henrik Bengtsson
<hb@maths.lth.se>, and David Brahm <brahm@alum.mit.edu>

References:

<URL: http://sudok...

Examples:

generateSudoku(print.it=TRUE)

Here's the function definition for those who understand R. I might make
pseudo-code from this if I have the time:

generateSudoku <- function(Nblank=50, print.it=FALSE) {
z <- c(1:9,4:9,1:3,7:9,1:6,2:9,1,5:9,1:4,8:9,1:7,3:9,1:2,6:9,1:5,9,1:8)
z <- matrix(sample(9)[z], 9,9)
for (i in 1:5) z <- z[replicate(3, sample(3)) + 3*rep(sample(0:2),
each=3),
replicate(3, sample(3)) + 3*rep(sample(0:2),
each=3)]
for (bi in seq(0,6,3)) for (bj in seq(0,6,3)) {
idx <- data.matrix(expand.grid(bi + 1:3, bj + 1:3))
z[idx[sample(1:9, Nblank%/%9), ]] <- 0
}
## Depopulate (if we had a test for uniqueness, we'd put it here):
while (sum(!z) < Nblank) z[matrix(sample(9,2), 1)] <- 0
if (print.it) printSudoku(z)
z
}



Meino Christian Cramer wrote:
> Hi,
>
> with Google I found a Quiz about a Sodoku-solver, but I didn't find a
> Sodoku generator. Also RAA and RubyForge did not list one.
>
> Is there any out there ? May be one, which also generated a solution
> for the generated Sodokus?
>
> Kind regards,
> mcc
>
>
>

--
M. Edward (Ed) Borasky

http://linuxcapacitypl...



Josef 'Jupp' Schugt

2/19/2006 10:18:00 PM

0

Hi!

At Mon, 20 Feb 2006 04:08:01 +0900, Meino Christian Cramer wrote:

> with Google I found a Quiz about a Sodoku-solver, but I didn't find
> a Sodoku generator. Also RAA and RubyForge did not list one.
>
> Is there any out there ? May be one, which also generated a solution
> for the generated Sodokus?

http://www...

I understand that you rather seek for a program but ... hand-made
Sudoku are much more fun than those created by software. Up to now at
least.

Josef 'Jupp' Schugt
--
07°09'58" E
50°40'08" N


Stephen Waits

2/20/2006 2:36:00 AM

0


On Feb 19, 2006, at 2:18 PM, Josef 'Jupp' SCHUGT wrote:

> I understand that you rather seek for a program but ... hand-made
> Sudoku are much more fun than those created by software. Up to now at
> least.

This is slightly OT, so I'll only offer this one contribution..
There is no such thing as hand-made sudoku puzzles at this point.
Yes, some newspapers still make the claim, but it's simply untrue.

--Steve



Hal E. Fulton

2/20/2006 2:40:00 AM

0

Stephen Waits wrote:
>
> On Feb 19, 2006, at 2:18 PM, Josef 'Jupp' SCHUGT wrote:
>
>> I understand that you rather seek for a program but ... hand-made
>> Sudoku are much more fun than those created by software. Up to now at
>> least.
>
>
> This is slightly OT, so I'll only offer this one contribution.. There
> is no such thing as hand-made sudoku puzzles at this point. Yes, some
> newspapers still make the claim, but it's simply untrue.

I think I'm the last person in the world to "get" this phenomenon.
I've never tried it, but it looks as exciting as solving the same
crossword puzzle over and over.

I guess it's the Rubik's Cube of the 00's, for whatever that may
be worth.


Hal



Meino Christian Cramer

2/20/2006 3:54:00 AM

0

Josef 'Jupp' Schugt

2/21/2006 7:32:00 PM

0

Hi!

At Mon, 20 Feb 2006 12:53:50 +0900, Meino Christian Cramer wrote:
> :) Thanks for the link!

It was taken from "Sudoku - Das original japanische Zahlenrätsel" by
Puzzler, published by MZV Moderner Zeitschriften Vertrieb GmbH &
Co. KG - http://w...

There is already quite a number of sudoku in print in Germany but
according to me this one bringst the most fun (I tried several
publications)

Josef 'Jupp' Schugt
--
50°40'8"N/7°9'58"E = 50°40.1333'N/7°9.9667'E = 50.668889°/7.166111°