Thanks Marko, I rather find DCL very interesting
BTW I think it would be handy if someone wrote an
UnSolvedSudokuGenerator routine, that will return a sudoku list (like in our inputs) to be solved.
The only way I could figure out to start with is this:
; note: 'x' stands for nil symbol (I used it for a better readability)
(foo n)
->
'( ; argument 'n' will fill for each Sector n amounth of random [1-9] items
(x x x x x x x x x)
(x x x x x x x x x)
(x x x x x x x x x)
(x x x x x x x x x)
(x x x x x x x x x)
(x x x x x x x x x)
(x x x x x x x x x)
(x x x x x x x x x)
(x x x x x x x x x)
)
; Examples:
(foo 1) -> ; Hard/Impossible ?
'( ; argument 'n' will fill for each Sector n amounth of random [1-9] items
(1 x x x x x x x x)
(x x x x 3 x x x 7)
(x x x x x x x x x)
(x x x 4 x x x x x)
(x 3 x x x x x x x)
(x x x x x x x x 2)
(x x x x x x x 5 x)
(2 x x 6 x x x x x)
(x x x x x x x x x)
)
(foo 2) -> ; Medium/Hard ?
'( ; argument 'n' will fill for each Sector n amounth of random [1-9] items
(x 2 x x x 5 x x x)
(3 x x x x x x x x)
(x x x 4 x x 1 5 x)
(x x 6 x x 3 x x 1)
(x 1 x x 7 x x x x)
(x x x x x x 9 x x)
(x x x 2 x x x x 7)
(x x 2 x x 1 x x x)
(x 6 x x x x x 8 x)
)
(foo 3) -> ; Easy/Medium
'( ; argument 'n' will fill for each Sector n amounth of random [1-9] items
(x 2 x x x 5 x 4 x)
(3 x x x 1 x x x x)
(x x 4 4 x x 1 5 x)
(x x 6 x x 3 x x 1)
(x 1 x x 7 x x x x)
(5 x x 8 x x 9 x 4)
(1 x x 2 x x 2 x 7)
(x x 2 x x 1 x x x)
(x 6 x x 3 x x 8 x)
)
To split the above task, maybe just generate a different (1 2 3 4 5 6 7 8 9) lists, say given 'n = 3', generate list with random [1-9] numbers on random positions of the list.
Say 9 list outputs like: (nil nil 2 nil 9 nil 6 nil nil) merged into assoc list.
Then use Lee's
bar subfunction he posted in Reply #10 to re-assemble the whole list.
Might be required
IsUnSolvedSudokuValid function.
Ofcourse before giving any return, must make sure generator's output to be valid/solvable, hence should be wrapped within a loop and tested if the sudoku is solvable(with a routine like Stefan's).
I know my idea doesn't cover all types unsolved sudoku generators, since 'n' amount is not fixed always for the sectors, but would be a good start.
Then, the future ideas for the DCL work would be:
Initial Dialog Prompt with Buttons (choose difficulty):
[Easy/Medium]
[Medium/Hard]
[Hard/Impossible]
And after all this, the top of the cake would be to make it competitive, where each user collects points for different solved sudoku.
+ wrapping all posted suggestions in this thread will make the overall code better (like including buttons [I'm giving up, show answer] ).