https://github.com/poyea/ternary-balance
⚖️ Python solver for the balance problem
https://github.com/poyea/ternary-balance
hacktoberfest math problem-solving python python-3 python3 sphinx sphinx-doc ternary
Last synced: 12 months ago
JSON representation
⚖️ Python solver for the balance problem
- Host: GitHub
- URL: https://github.com/poyea/ternary-balance
- Owner: poyea
- License: mit
- Created: 2020-05-06T01:05:31.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-07-25T20:50:37.000Z (almost 3 years ago)
- Last Synced: 2025-06-20T00:08:46.989Z (12 months ago)
- Topics: hacktoberfest, math, problem-solving, python, python-3, python3, sphinx, sphinx-doc, ternary
- Language: Python
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ternary Balance System
> Given an integer N, find a way to balance the integer with weights from the set {1, 3, 9, 27, ...}, i.e. the powers of 3.

* [Features](#features)
* [Getting started](#getting-started)
* [Usage](#usage)
* [Run tests](#run-tests)
* [Build the documentation](#build-the-documentation)
* [Style](#style)
* [License](#license)
## Features
* Solve the ternary balance problem
* Provide numeric utilities for exploration and testing
## Getting started
Make sure your Python is up-to-date:
```
$ python --version
Python 3.8.2
```
Set up a python environment:
```
$ python -m venv ternary
```
Install the requirement:
```
(ternary) $ pip install -r requirements.txt
```
## Usage
One query:
```python
from ternary_balance.solver import ternary_balance
solver = ternary_balance()
solver.solve()
```
Many queries:
```python
from ternary_balance.solver import ternary_balance
solver = ternary_balance()
for _ in range(10):
solver.solve()
```
## Run tests
To run the doctests,
```
(ternary) $ cd ternary_balance/utils
(ternary) $ python numerics.py -v
```
## Build the documentation
To use Sphinx with Napoleon,
```
(ternary) $ cd docs
(ternary) $ sphinx-apidoc --version
sphinx-apidoc 3.0.3
(ternary) $ sphinx-apidoc -o . ..
(ternary) $ make html
```
The documentation is available in `docs/_build`.
## Style
To format the code, run
```
(ternary) $ black .
```
## License
MIT