Skip to content

A sudoku solver in ruby as a little get-to-know-ruby project.

Notifications You must be signed in to change notification settings

truggeri/ruby-sudoku

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ruby Sudoku

Test Coverage Badge

Ruby Badge GHA Badge

The purpose of this project is to get a little practice with Ruby. The idea is that this will serve as a sudoku solver.

Running

To run the project locally, install the dependencies using Bundler, then run with.

bundle install
bundle exec ruby lib/sudoku/run_local.rb

Algorithm

This section will describe the algorithm used to solve the puzzels. The basic idea is this.

  1. Find the possible options for each empty space
  2. Examine space-by-space for places with:
    1. Only one possibility
    2. Only space in the row with a possibility
    3. Only space in the column with a possibility
    4. Only space in the block with a possibility

Input

This section will describe how to interface with the project. Ideally, I will include a web/HTTP api (using something like Sinatra), but that may be after the core of the application.

Load from a file

When the application starts, it will request the path to a file that contains a puzzle. The puzzle file should be nine lines long. Each line contains a space seperated list of entries. Each entry is either a number if given in the puzzle or a dash to indicate the space is blank.

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

Tests

There is a test suite written with rspec. Run it with,

bundle exec rspec ./spec/

Linting

bundle exec rubocop -D

About

A sudoku solver in ruby as a little get-to-know-ruby project.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages