This is a toy project intended for a novice programmer to collect basic experience of working with Common Lisp.
This project features code for solving 9x9 sudoku puzzles.
Instructions are given for command-line interface, which means
that you are required to type the code below in the terminal.
Whenever the line is prefixed with $
, it means that it needs
to be executed with your regular user permissions. #
means
that you need root
user permissions to execute the code.
# yum install git curl sbcl emacs $ cd ~ $ curl -O http://beta.quicklisp.org/quicklisp.lisp $ sbcl --load quicklisp.lisp
Follow instructions found here in order to complete
Quicklisp
installation.
Now, using sbcl
and Quicklisp
install quicklisp-slime-helper
$ sbcl --eval '(ql:quickload :quicklisp-slime-helper)' $ echo '(load (expand-file-name "~/quicklisp/slime-helper.el"))' \ >> ~/.emacs.d/init.el $ echo '(setq inferior-lisp-program "sbcl")' >> ~/.emacs.d/init.el
Let’s download our project!
$ cd ~/quicklisp/local-projects $ git clone https://github.com/wvxvw/sudoku-solver.git
Now you should be all set up for experimenting! Start Emacs:
$ emacs
Load SLIME:
M-x slime
Load project (once in the REPL buffer):
(ql:quickload :sudoku-solver)
Follow the steps for RHEL, but replace yum
with apt-get
.
Start Lisp, for example:
$ sbcl
Load sudoku-solver
system:
(ql:quickload :sudoku-solver)
Execute tests:
(asdf:oos 'asdf:test-op :sudoku-solver)
$ sbcl
(ql:quickload :sudoku-solver)
(ql:quickload :sudoku-solver-doc)
(asdf:oos 'sudoku-solver-asd:doc-op :sudoku-solver)
(ql:quickload :sudoku-solver)
(in-package :sudoku-solver)
(defparameter *simple-board*
(make-array
'(9 9)
:initial-contents
'((0 0 0 1 0 5 0 6 8)
(0 0 0 0 0 0 7 0 1)
(9 0 1 0 0 0 0 3 0)
(0 0 7 0 2 6 0 0 0)
(5 0 0 0 0 0 0 0 3)
(0 0 0 8 7 0 4 0 0)
(0 3 0 0 0 0 8 0 5)
(1 0 5 0 0 0 0 0 0)
(7 9 0 4 0 1 0 0 0))))
;; This will return a solved board
(sudoku-solver:solve *simple-board*)
TBD
First, do it for Ubuntu, I should have a VM somewhere, then try to find some Windows machine to test it on. This is the bit of code that is missing yet. Once this starts to work, add some tests, use5am
to write them.
Some tests could be used as examples, but probably I’d need more.
The program could use some nice interface, like, display visually
the process of solving. Probably simple printing to the terminal
will do.