GithubHelp home page GithubHelp logo

moygit / exact_cover_np Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 3.0 35 KB

Finding exact covers in NumPy (and solving Sudoku!)

License: GNU General Public License v2.0

C 65.08% Python 23.33% Makefile 11.59%

exact_cover_np's People

Contributors

moygit avatar

Stargazers

 avatar  avatar

Watchers

 avatar

exact_cover_np's Issues

segfault and wrong answer

Hi,

Thanks for writing this. Here are some corner cases:

import exact_cover_np
import numpy as np

exact_cover_np.get_exact_cover(np.array([[1,0,0],[0,1,1]],dtype=np.int32))
#array([0, 0], dtype=int32)

exact_cover_np.get_exact_cover(np.array([[1,1,1]],dtype=np.int32))
#Segmentation fault (core dumped)

Incremental construction of sparse matrix

Currently the entire matrix is created in Python and then passed whole to the C code, which then translates it into a sparse matrix. So the example on the front page says S = ... and then calls get_exact_cover(S). If this matrix is large, though, the caller might prefer to construct it piecemeal, say row by row, and pass each row to the C code to be sparsified individually.

What this means in code: currently get_exact_cover (or, more precisely, dlx_get_exact_cover) calls create_sparse_matrix. A more flexible and memory-efficient approach, though less time-efficient, would be to have an API like init_create_sparse_matrix, add_row_to_sparse_matrix, and done_creating_sparse_matrix.

Python 3

Hi Moy,

Thanks for this code!

I've made a few updates to get it working with Python 3. (They break Python 2 compatibility but I figured that was ok since it's end-of-lifed. Making it work with both shouldn't be too much harder.) You can see what I've done at jwg4#1

I just wondered whether you would care to merge these in. If you're not bothered, I might submit to pypi under a slightly different name? Let me know what you think.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.