Skip to main content

Solve open the lock puzzle.

Project description

Opener

Build Status codecov PyPI PyPI - Python Version Lines of code GitHub code size in bytes GitHub contributors PyPI - License

Opener is a puzzle solver Python package. Currently it solves the Open the lock puzzle. The package can be found in the Python Package Index (PyPI).

This package can be used on Linux/Unix, Mac OS and Windows systems.

Features

  • Get keys for Open the lock puzzle.

Installation

You can install the opener from PyPI:

pip install opener

The opener is supported on Python 2.7, as well as Python 3.4 and above.

How to use

Example 1

Three Digits Open the Lock Puzzle Example

The above figure outlines a three digits Open the Lock puzzle. A valid unlock key of the above puzzle is: 679

example_1.py shows how to use opener package to solve the above puzzle.

Solution of the above Open the lock puzzle:

from opener import get_keys

number_of_positions = 3
invalid_digits = (5, 2, 3)
similarity_conditions = (
    ([9, 6, 4], 2),
    ([2, 8, 6], 1),
    ([1, 4, 7], 1),
    ([1, 8, 9], 1)
)
invalid_positioned_values = ((9, 1), (6, 8, 4), (4, 6, 7))
valid_positioned_values = ((1,), (8,), (9,))
unlock_keys = get_keys(number_of_positions,
                       similarity_conditions,
                       invalid_digits,
                       invalid_positioned_values,
                       valid_positioned_values)
for key in unlock_keys:
    print(key)
    # 679

Example 2

Four Digits Open the Lock Puzzle Example

The above figure outlines another Open the Lock puzzle with four digits combination. A valid unlock key of the above puzzle is: 9876

example_2.py shows how to use opener package to solve the above puzzle.

Solution of the above Open the lock puzzle:

from opener import get_keys

number_of_positions = 4
invalid_digits = (5, 1, 2, 4)
similarity_conditions = (
    ([3, 5, 4, 8], 1),
    ([4, 6, 7, 1], 2),
    ([3, 7, 8, 1], 2),
    ([8, 3, 9, 7], 3),
    ([2, 9, 3, 4], 1),
    ([5, 1, 3, 6], 1),
)
invalid_positioned_values = ((3, 8, 2), (5, 7, 3, 9),
                             (4, 8, 9, 3), (8, 1, 7, 4))
valid_positioned_values = ((5,), (1,), (3,), (6,))
unlock_keys = get_keys(number_of_positions,
                       similarity_conditions,
                       invalid_digits,
                       invalid_positioned_values,
                       valid_positioned_values)
for key in unlock_keys:
    print(key)
    # 9876

Authors

Contribute

Contributions are welcome from the community. Questions can be asked on the issues page. Before creating a new issue, please take a moment to search and make sure a similar issue does not already exist. If one does exist, you can comment (most simply even with just a :+1:) to show your support for that issue.

If you have direct contributions you would like considered for incorporation into the project you can fork this repository and submit a pull request for review.

Please read the development guideline before contribution.

Changelog

0.0.3 (2020-10-03)

  • Added four digits open the lock example
  • Updated tests
  • Updated readme
  • Separated development guideline
  • Added pylint and flake8

0.0.2 (2020-10-02)

  • Release to PyPI

0.0.1 (2020-10-01)

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for opener, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size opener-0.0.4-py3-none-any.whl (5.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size opener-0.0.4.tar.gz (139.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page