Giter Site home page Giter Site logo

mahdi-torabian / cryptarithmetic Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dwave-examples/cryptarithmetic

0.0 0.0 0.0 123 KB

Solve cryptarithmetic addition puzzles using the LeapHybridCQMSampler.

License: Apache License 2.0

Python 100.00%

cryptarithmetic's Introduction

Open in GitHub Codespaces Linux/Mac/Windows build status

Cryptarithmetic Addition

Cryptarithmetic puzzles are logical puzzles where the goal is to have unique assignments of digits to letters, such that the mathematical expression holds true. This demo only runs with addition puzzles.

Usage

To run this demo, execute:

python cryptarithm.py --filename path/to/your/file.txt

For simplicity and to establish convention, ensure all letters are capitalized, that the puzzle be written on the first line of the file, and that no more than 10 unique letters are used in total.

For example:

python cryptarithm.py --filename puzzle_files/example1.txt

Could produce:

Solution found for SEND + MORE = MONEY, 9567 + 1085 = 10652

There are three puzzle files provided in the puzzle_files directory. If no puzzle file is specified, puzzle_files/example1.txt is used by default.

Code Overview

Constraints considered in problem formuation:

  1. The first constraint is that the left-hand side must be equal to the right-hand side.
  2. Assignments of digits to letters must be unique, thus a puzzle may contain no more than 10 unique letters. This is expressed as a series of encoded not-equal constraints.
  3. The first letters must be assigned a non-zero digit, unless the puzzle contains one letter words.

References

Wiki page on verbal arithmetic.

License

Released under the Apache License 2.0. See license here.

cryptarithmetic's People

Contributors

hbarovertwo avatar hemantdwave avatar randomir avatar

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.