higher-lower
Functions for finding numbers using higher/lower
Installation
Install this library using pip:
$ pip install higher-lower
higher_lower(min_value, max_value, callback)
The higher_lower() function searches for a value between min_value and max_value, calling callback() for each candidate value to see if the target is higher or lower.
min_value- the lowest possible valuemax_value- the highest possible valuecallback(candidate)- a callback function that takes a single integer argument and returnsActualIs.MATCH,ActualIs.HIGHERorActualIs.LOWER
For example:
from higher_lower import ActualIs
def callback(candidate):
if candidate == 7:
return ActualIs.MATCH
elif candidate > 7:
return ActualIs.LOWER
else:
return ActualIs.HIGHER
Given the above callback function, a search can be made for the number between 0 and 100 like so:
from higher_lower import higher_lower
number = higher_lower(0, 100, callback)
# number is now 7
Development
To contribute to this library, first checkout the code. Then create a new virtual environment:
cd higher-lower
python -mvenv venv
source venv/bin/activate
Or if you are using pipenv:
pipenv shell
Now install the dependencies and tests:
pip install -e '.[test]'
To run the tests:
pytest
Metadata
Release files for higher-lower 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| higher-lower-0.1.tar.gz | 2.5 kB | Without provenance | Details for higher-lower-0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| higher_lower-0.1-py3-none-any.whl | Python 3 | none | any | Details for higher_lower-0.1-py3-none-any.whl |
Total release size: 9.1 kB
Release files / higher-lower-0.1.tar.gz
| Download URL | higher-lower-0.1.tar.gz |
|---|---|
| Size | 2.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
796d7148d0123f6001bbb761bc64eedc02cfcc72b68e38215fa9c15ff6355bb1
|
|
BLAKE2b-256 checksum How to use checksums |
e695748ff07e48d2c1c21610b27a21cb77bd51a3682eea4d8fd1cc208490d278
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
|
Release files / higher_lower-0.1-py3-none-any.whl
| Download URL | higher_lower-0.1-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b140cf347e0a414d8c90762923ea246beef1b9130c91dacf7b4144b02a91652b
|
|
BLAKE2b-256 checksum How to use checksums |
c64cbe7831ea3d5f4afd234b837a7324983096d3543e5cd5ee287296ca169f59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
|
Security for higher-lower 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.