Sudoku in TCL

After doing the Sudoku implementation in Python I ported the code to TCL as to do some first steps in this language. It took me some time to cope with the TCL syntax, but there it is.

Sadly the solution isn't really object oriented, creating the namespace will only create one copy of the Sudoku field. I found a solution with http://www.tcl.tk/man/tcl8.5/tutorial/Tcl31.html but this needs TCL 8.5.

% source sudoku.tcl
% sudoku::create
% sudoku::setRandomFields
% sudoku::toString
|2|_|3| |6|_|1| |_|_|_|
|_|6|_| |9|_|_| |_|_|_|
|_|5|_| |_|_|_| |_|_|3|

|_|_|4| |_|9|_| |8|_|_|
|1|_|_| |_|_|6| |3|_|_|
|_|9|_| |7|_|_| |_|_|2|

|_|_|_| |8|_|4| |_|_|_|
|8|_|_| |_|_|_| |_|6|_|
|_|_|_| |_|6|_| |9|_|5|
% sudoku::solveBruteForce
1
% sudoku::toString
|2|4|3| |6|8|1| |5|9|7|
|7|6|1| |9|3|5| |4|2|8|
|9|5|8| |4|7|2| |6|1|3|

|5|2|4| |1|9|3| |8|7|6|
|1|8|7| |5|2|6| |3|4|9|
|3|9|6| |7|4|8| |1|5|2|

|6|7|9| |8|5|4| |2|3|1|
|8|3|5| |2|1|9| |7|6|4|
|4|1|2| |3|6|7| |9|8|5|

Same as the implementation in Python: released under the MIT license.

AttachmentSize
sudoku.tcl6.4 KB