Skip to content

Welcome to Digits Solver, an indispensable Python program designed to conquer the Digits puzzle game, developed by New York Time.

License

Notifications You must be signed in to change notification settings

yuchuehw/DigitsSolver

Repository files navigation

Digits Solver icon

English • 繁體中文简体中文日本語EspañolFrançaisItalianoDeutscheРусский

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!

Python application CodeQL PyLint Score
python badge Selenium TimeShift contributions welcome License Code style: black HitCount

Demo

See the algorithm in action by clicking the green run button after being redirected:

Replit

You can also watch this speed run that uses

the Digits Solver algorithm:

Replit

Note: The demo showcases the solve_auto feature. Continue reading for more information.

Table of Contents

Installation

You can obtain a copy of the Digits Solver program using one of the following methods:

  1. Clone the Repository:

    git clone https://github.com/yuchuehw/DigitsSolver.git
  2. 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.

Usage

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.

Examples

  1. Find all solutions for the digits puzzle:

    python solver 3 12 15 20 23 25 439
  2. Find only one solution for the digits puzzle:

    python solver 3 12 15 20 23 25 439 -os
  3. 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

Output

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)

Alternative Usage

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)")

Util Modules

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:

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.

Contributing

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.

License

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.

Acknowledgements

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.

About

Welcome to Digits Solver, an indispensable Python program designed to conquer the Digits puzzle game, developed by New York Time.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published