Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Sudoku: Round 2
Just curious, what would that look like (i.e., the plain SQL version)?
Also has anybody tried the sudoku code Mr Morgan posted on his website? I copied and pasted it and it doesn't seem to work. I think part of the problem is in the get_row_string function, but since I'm hardly an expert with PL/SQL I'm not 100% sure:
IF colno = 1 THEN
sstr := 'SELECT col2 || col3 || col4 || col5 || col6 || col7 ||
col8 || col9 ' || fclause || TO_CHAR(rowno);
ELSIF colno = 2 THEN
sstr := 'SELECT col1 || col3 || col4 || col5 || col6 || col7 ||
col8 || col9 ' || fclause || TO_CHAR(rowno);
ELSIF colno = 3 THEN
sstr := 'SELECT col1 || col2 || col4 || col5 || col6 || col7 ||
col8 || col9 ' || fclause || TO_CHAR(rowno);
ELSIF colno = 4 THEN
sstr := 'SELECT col1 || col2 || col3 || col5 || col6 || col7 ||
col8 || col9 ' || fclause || TO_CHAR(rowno);
ELSIF colno = 5 THEN
sstr := 'SELECT col1 || col3 || col4 || col2 || col6 || col7 ||
col8 || col9 ' || fclause || TO_CHAR(rowno);
ELSIF colno = 6 THEN
sstr := 'SELECT col1 || col3 || col4 || col5 || col2 || col7 ||
col8 || col9 ' || fclause || TO_CHAR(rowno);
ELSIF colno = 7 THEN
sstr := 'SELECT col1 || col3 || col4 || col5 || col6 || col2 ||
col8 || col9 ' || fclause || TO_CHAR(rowno);
ELSIF colno = 8 THEN
sstr := 'SELECT col1 || col3 || col4 || col5 || col6 || col7 ||
col2 || col9 ' || fclause || TO_CHAR(rowno);
ELSIF colno = 9 THEN
sstr := 'SELECT col1 || col3 || col4 || col5 || col6 || col2 ||
col8 || col2 ' || fclause || TO_CHAR(rowno);
END IF;
The colno = 9 scenario doesn't make sense...why would you want col2 in
the string twice?
Anyway, just thought I'd share... Have a wonderful day.
Michel Cadot wrote:
> "DA Morgan" <damorgan_at_psoug.org> a écrit dans le message de news: 1157178445.621662_at_bubbleator.drizzle.com...
> | School starts again in October so I've a bit of time on my hands until
> | then. And, realizing I had a lot of important things I needed to get
> | done, instead I revisited my previous attempt at a PL/SQL Sudoku solver.
> |
> | I know there are a couple of solutions in Perl that are written in 2-3
> | lines of code ... but their methodology is brute force and I find that
> | inelegant so I went back to my original solution and added three more
> | layers of sophistication.
> |
> | I haven't been able to find a puzzle that can defeat it but I am hoping
> | someone can. If you want to try ... www.psoug.org and click on PSOUG
> | Sudoku Challenge in the bottom right quadrant.
> |
> | Create two tables (sudoku and possibles) followed by three functions and
> | a single procedure.
> |
> | Now I know the code needs a huge amount of cleaning up, bind variables,
> | more use of NDS, put it all into a package, etc. but before I spend
> | time on that I am hoping someone will beat it into submission.
> |
> | Let the game begin.
> | --
> | Daniel Morgan
> | Puget Sound Oracle Users Group
>
> Why PL/SQL? It can be done with just SQL.
>
> Let the game bounce.
> Michel Cadot
Received on Wed Sep 27 2006 - 11:42:58 CDT