English • 繁體中文 • 简体中文 • 日本語 • Español • Français • Italiano • Deutsche • Русский
Welcome to Digits Solver, the ultimate Python companion for conquering the mind-bending Digits puzzle game, developed by The New York Times. Dive into a captivating world of numerical challenges and master the art of strategic manipulation. With Digits Solver, you'll strategically manipulate a set of starting digits using mathematical operations to reach the elusive target digit. Its powerful algorithm and meticulous analysis empower you to swiftly unravel each puzzle, delivering step-by-step solutions with unwavering precision. Elevate your puzzle-solving prowess and unlock the secrets hidden within the digits. Get ready for an exciting journey to become a Digits master!
See the algorithm in action by clicking the green run button after being redirected:
You can also watch this speed run that uses
the Digits Solver algorithm:
Note: The demo showcases the solve_auto feature. Continue reading for more information.
You can obtain a copy of the Digits Solver program using one of the following methods:
-
Clone the Repository:
git clone https://github.com/yuchuehw/DigitsSolver.git
-
Download the Zip File:
- Go to the Release tab on the GitHub repository.
- Download the latest release zip file.
- Extract the contents of the zip file to your desired location.
After obtaining the program, you can proceed to the Usage section to run the Digits Solver program.
To run the Digits Solver program, open the terminal and navigate to the directory where you have downloaded or cloned the DigitsSolver repository. Once you are in the appropriate directory, execute the following command in the terminal (replace values in angle brackets with your input; see Examples section section for more details):
python solver <starting_digits> <target_digit> [-os] [-h]
<starting_digits>
: A space-separated list of integers representing the starting digits.<target_digit>
: The target digit that needs to be obtained.-os
or--onesolution
(optional): If specified, the program will find only one solution. Otherwise, it will find all possible solutions.-h
or--help
(optional): If used, the help menu will be displayed.
-
Find all solutions for the digits puzzle:
python solver 3 12 15 20 23 25 439
-
Find only one solution for the digits puzzle:
python solver 3 12 15 20 23 25 439 -os
-
Note starting_digits always go before target_digits. This is an example of puzzle with 8 starting_digits:
python solver 2 3 5 7 11 13 17 19 21 -os
The program will output the number of solutions found and display each solution in the following format:
Solution found:
15 + 3 = 18
23 × 18 = 414
414 + 25 = 439
We found 1 solution(s)
The Digits Solver can also be imported as a Python module and used programmatically. You are free to add more functionality than what we have provided. Here's a minimal example of how to use it as an import:
from solver.solver import DigitSolver
solver = DigitSolver([3, 12, 15, 20, 23, 25], 439)
# False in the paranthesis is optional. False solve all solution. True solve one solution.
# use solve.printer = some_function to override default output behavior.
solution_count = solver.solve(False)
print(f"We found {solution_count} solution(s)")
We have also included a few additional Python programs that complement the solver program. They are located inside the solver/util folder. You can read more about how to use them here:
- How to Use pretty_solve.py: Provides a visually enhanced version of the solver program.
- How to Use solve_auto.py: Fully automatic Digits solver with Selenium
Feel free to explore these files and utilize them for specific use cases or scenarios.
Appendix folder includes 450 problems used in the NYT Games. Feel free to use those problems for program testing.
Contributions to the Digits Solver program are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.
When contributing, please ensure that you follow best practices, maintain code quality, and provide clear descriptions of your changes.
The Digits Solver program is licensed under the MIT License. You are free to use, modify, and distribute this program for personal or commercial purposes. Please see the LICENSE file for more details.
Special thanks to the author of timeshift.js for their contribution to this project. Portions of their code have been utilized in the implementation of the solver.util module.