Skip to content

wvxvw/sudoku-solver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

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.

Obtaining

GNU/Linux

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.

RHEL (Fedora Core, CentOS)

# 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)

Debian (Ubuntu, Mint)

Follow the steps for RHEL, but replace yum with apt-get.

Testing

Start Lisp, for example:

$ sbcl

Load sudoku-solver system:

(ql:quickload :sudoku-solver)

Execute tests:

(asdf:oos 'asdf:test-op :sudoku-solver)

Generating Documentation

$ sbcl
(ql:quickload :sudoku-solver)
(ql:quickload :sudoku-solver-doc)
(asdf:oos 'sudoku-solver-asd:doc-op :sudoku-solver)

Running

(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*)

Bugs

TBD

Tasks

Write and test installation on other systems

First, do it for Ubuntu, I should have a VM somewhere, then try to find some Windows machine to test it on.

Implement backtracking

This is the bit of code that is missing yet.

Write tests

Once this starts to work, add some tests, use 5am to write them.

Add examples

Some tests could be used as examples, but probably I’d need more.

Add some interface

The program could use some nice interface, like, display visually the process of solving. Probably simple printing to the terminal will do.

About

Toy project for solving Sudoku 9x9 puzzles

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published