Skip to main content

Pyjail Math

Build basic arithmetic expressions that evaluate to given numbers.

from pyjailmath.builder import PyjailMathBuilder

pmb = PyjailMathBuilder(
    '0', '1', '1+1', '-1', '-1-1',  # should evaluate to 0, 1, 2, -1, -2, respectively
    (r'(.+)', r'(\1)'),  # regex replace pattern to force operator precedence
    {'+', '-', '-unary', '*', '**', '//', '^', '~'},  # allowed operators
)
pmb.add_number_mappings({3: '3'})  # additional expressions

# Precompute small values
pmb.precompute_numbers([i for i in range(2, 1000)])
pmb.precompute_numbers([i**2 for i in range(2, 80)])
pmb.precompute_numbers([i**3 for i in range(2, 50)])
pmb.precompute_numbers([i**4 for i in range(2, 30)])

# Compute big value
print(pmb.get_number(133713371337))  # (((~3*~3*3*~3+1)*(~(3**3-~3)**(1+1)))*(3*((3)*(-3*3*~3-3))**(3)-3))//(1+3)

Installation

Install pyjailmath from PyPI using pip.

python3 -m pip install --upgrade pyjailmath

Download files

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

Source Distribution

pyjailmath-0.0.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyjailmath-0.0.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file pyjailmath-0.0.0.tar.gz.

File metadata

  • Download URL: pyjailmath-0.0.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.3

File hashes

Hashes for pyjailmath-0.0.0.tar.gz
Algorithm Hash digest
SHA256 11d1df8acaaef78a3b2ed7612da7dc02e764cc975af8c9a676b3d9516159b68f
MD5 9f665a63453abd30dfb37a67ea344f6d
BLAKE2b-256 07680534d4edd92c4fa283b5c361a5f876a72685b87e183344fcc304ad8093f7

See more details on using hashes here.

File details

Details for the file pyjailmath-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyjailmath-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.3

File hashes

Hashes for pyjailmath-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 31961209dbeae43ccf6c645496fa75a823eee5fbb165bca0725d938125d6218b
MD5 40454870b0bb9fe34fa13ef46be678c9
BLAKE2b-256 9c0c9189e63d042187e3a79f9334fcd189049760a8ba1979234f87e433874706

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page