Project

dlx

0.0
No commit activity in last 3 years
No release in over 3 years
Dancing Links - Finding all solutions to the exact cover problem
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.10
~> 10.0
 Project Readme

Ruby Dancing Links

What is it?

Dancing links, also known as DLX, is the technique suggested by Donald Knuth to efficiently implement his Algorithm X. More

"Algorithm X" is the name Donald Knuth used in his paper "Dancing Links" to refer to "the most obvious trial-and-error approach" for finding all solutions to the exact cover problem.

The exact cover problem is represented in Algorithm X using a matrix A consisting of 0s and 1s. The goal is to select a subset of the rows so that the digit 1 appears in each column exactly once. More

Installation

gem install dlx

Usage

require 'dlx/sparse_matrix'

matrix = Dlx::SparseMatrix.new
matrix.add("1001001")
      .add("1001000")
      .add("0001101")
      .add("0010110")
      .add("0110011")
matrix << "0100001"
solutions = matrix.solve

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

See LICENSE