Git Product home page Git Product logo

imatchstick's Introduction

iMatchstick - Matchstick Arithmetic Puzzle Solver and Beyond

Basic Problem to Solve

Digits composed of matchsticks are listed as following:

Digits

A, B, C are nonnegative integers and we have A, B < 100, and C < 200. Input an equation in forms of A+B=C or A-B=C with ONE matchstick misplaced like this:

Sample Puzzle

List ALL answer(s) to this puzzle to correct the equation by moving ONLY ONE matchstick.

["49+68=117"]

Examples

Example 1

Example 2

Example 3

Example 4

Example 5

Optional Bonus Problem to Solve

Given the number of sticks to move, output all answers to a puzzle.

For example, given 2 as the number of sticks to move and

Sample Bonus Puzzle

the answers are: ["3+9=12","8+4=12"]

Given 3 as the number of sticks to move and the same puzzle, the answers are:

Notice

  • A legal puzzle follows this regular expression pattern: \d{1,2}[+-]\d{1,2}=\d{1,3}.

  • Plus sign + can be changed to minus sign - by moving a matchstick off and minus sign - can be changed to Plus sign + by adding a matchstick.

  • Equal sign= should not be changed.

  • The two sticks of 1 should only lie on the right side of the digit.

  • Stick can ONLY be moved from and to the EXISTING digit(s) or the operator sign. For example, the basic problem 8-1=1 has the only correct answer 0+1=1, while 0-1=-1 is not the answer. Given 2 as the number of sticks to move, the bonus problem 10+3=8 has the only correct answer 18-9=9, while 10+3=13 is not the answer.

  • Completely removal of a digit is not allowed. For example, given 2 as the number of sticks to move, the bonus problem 6+3=14 has the only correct answer 9+5=14, while 6+3=9 is not the answer.

imatchstick's People

Contributors

kingmario avatar

Stargazers

Jackson Paredes Ferranti avatar  avatar  avatar  avatar Kevin avatar PageNotFound avatar

Watchers

James Cloos avatar  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.