Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 9 days 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 (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-12-12T12:34:59.000Z (almost 2 years ago)
- Last Synced: 2023-03-04T01:43:21.904Z (over 1 year ago)
- Topics: hacktoberfest, math, problem-solving, python, python-3, python3, sphinx, sphinx-doc, ternary
- Language: Python
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
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.![Ternary Balance](https://github.com/poyea/ternary-balance/workflows/Ternary%20Balance/badge.svg)
* [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_balancesolver = ternary_balance()
solver.solve()
```
Many queries:
```python
from ternary_balance.solver import ternary_balancesolver = 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