Metadata-Version: 2.4
Name: pyjailmath
Version: 0.0.0
Summary: Build basic arithmetic expressions that evaluate to given numbers.
Author-email: Mario Chao <az0112mario@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/MarioChao/pyjail-math
Project-URL: Issues, https://github.com/MarioChao/pyjailmath/issues
Keywords: golf,pyjail,ctf,flag
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# Pyjail Math

Build basic arithmetic expressions that evaluate to given numbers.

```py
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.

```sh
python3 -m pip install --upgrade pyjailmath
```
