This project can solve matchstick puzzels and creates ones
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
This project solves any mathematical matchstick puzzels, This algorithm takes a string, for example: 6+4=4
, and will look for solutions. For this equation it will find 2:
0+4=4
8-4=4
For each one it will explain exactly how to solve.
example for the first one:
moved the middle of 6 to it's top right to make a 0
example for the second one:
added a matchstick to "-" (to make a "+") from the top right of "8" (to make a "6")
- Clone the repo
git clone https://github.com/KingOfTNT10/Matchstick_Algorithm-Python.git
- Install libraries:
pip install py_expression
To solve an equation you need to import the algorithm file and call the solve function:
import algorithm
solve_data = algorithm.solve("6+4=4")
print(solve_data)
To create an equation with answers:
import algorithm
# create_equation has one argument called answer, this argument decides what the answer for the random math problem should be
# example: algorithm.create_equation(answer=4)
# It would return for example:
# {'equation': '2+5=4', 'solutions': [{'new_equation': '2+2=4', 'original_equation': '2+5=4', 'explanation': "moved the top left of 5 to it's top right to make a 2"}]}
equation_data = algorithm.create_equation()
print(equation_data)
See the open issues for a full list of proposed features (and known issues).
This program is using a custom format to represent numbers, for example the number 5:\
This number is represented like this in the code (other examples can be found in stickData):
[
[1, 1, 0],
[0, 1, 1, 1]
]
Because we divide the number into 2 cells/rows:
And we number the sticks from left to right (counter-clock wise) (green
=1
, red
=0
):
So the first cell comes out as:
[1, 1, 0]
And the second:
[0, 1, 1, 1]
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Your Name - Ilai K - ilai.keinan@gmail.com
Project Link: https://github.com/KingOfTNT10/Matchstick_Algorithm-Python