A Python library for parsing and generating Fliggertiggybet numerals - an emoji-based numeral system
Project description
Fliggertiggybet ๐
A Python library for parsing and generating Fliggertiggybet numerals โ an emoji-based numeral system similar to Roman numerals.
๐ Background
Fliggertiggybet numerals are the number system used on the fictional planet Fliggertiggybet. They use emojis instead of letters and combine additive and subtractive notation to represent numbers from 1 to 3999.
Symbol Values
| Symbol | Value | Meaning |
|---|---|---|
| โ๏ธ | 1 | One finger |
| โ๏ธ | 2 | Two fingers (peace sign) |
| ๐ | 5 | Five fingers (OK sign) |
| โ | 10 | Open hand |
| ๐ | 50 | Both hands raised |
| ๐ฏ | 100 | Hundred points |
| ๐ | 500 | Celebration |
| ๐ | 1000 | Fireworks |
Notation Rules
-
Additive Notation: Symbols are written largest to smallest, left to right, and their values are added.
- Example:
๐โ๐= 50 + 10 + 5 = 65
- Example:
-
Subtractive Notation: When a smaller value precedes a larger value, subtract the smaller from the larger.
- Example:
โ๏ธโ= 10 - 1 = 9 - Example:
โโ๐ฏ= 100 - 10 - 10 = 80 - Valid subtractive pairs:
- โ๏ธ can precede โ (10) or ๐ (5)
- โ๏ธ can precede โ (10) or ๐ (5)
- โ can precede ๐ (50) or ๐ฏ (100)
- ๐ฏ can precede ๐ (500) or ๐ (1000)
- Example:
-
Repetition Limits:
- โ๏ธ, โ๏ธ, ๐, ๐, ๐ โ maximum 1 consecutive
- โ, ๐ฏ โ maximum 2 consecutive
- ๐ โ maximum 3 consecutive
-
Valid Range: 1 to 3999
๐ Installation
From PyPI (when published)
pip install fliggertiggybet
From Source
git clone https://github.com/slyu/Fliggertiggybet.git
cd Fliggertiggybet
pip install -e .
Development Installation
pip install -e ".[dev]"
pre-commit install
๐ป Usage
Command Line Interface
# Convert integer to Fliggertiggybet numeral
$ fliggertiggybet 42
42
โ๐โ๏ธ
# Convert Fliggertiggybet numeral to integer
$ fliggertiggybet โ๏ธโ
9
โ๏ธโ
# Invalid input handling
$ fliggertiggybet ๐๐๐ฅ๐ฏ๐ฏโ๐คโ๐โ๏ธ
Invalid Fliggertiggybet numeral
# Strict mode (enforce all rules)
$ fliggertiggybet --strict โโโ
Error: Symbol โ repeated 3 times (max allowed: 2)
Python Library
from fliggertiggybet import FliggertNumber, to_integer, to_fliggertiggybet
# Convert integer to Fliggertiggybet numeral
numeral = to_fliggertiggybet(42)
print(numeral) # โ๐โ๏ธ
# Convert Fliggertiggybet numeral to integer
value = to_integer("โ๏ธโ")
print(value) # 9
# Use the FliggertNumber class for an abstract data type
n = FliggertNumber(1987)
print(n.numeral) # ๐๐ฏ๐โโ๐ฏ๐โ๏ธ
print(n.value) # 1987
print(int(n)) # 1987
print(str(n)) # ๐๐ฏ๐โโ๐ฏ๐โ๏ธ
# Parse from numeral string
n = FliggertNumber.from_numeral("๐โ๐")
print(n.value) # 65
# Safe parsing (returns None on failure)
n = FliggertNumber.try_parse("invalid๐ฅ")
print(n) # None
# Arithmetic operations
a = FliggertNumber(10)
b = FliggertNumber(5)
result = a + b
print(result.value) # 15
# Comparison operations
print(a > b) # True
print(a == 10) # True
# Iteration over a range
for n in FliggertNumber.range(1, 5):
print(f"{n.value}: {n.numeral}")
# 1: โ๏ธ
# 2: โ๏ธ
# 3: โ๏ธ๐
# 4: โ๏ธ๐
Strict vs Lenient Mode
Following Postel's Law, the library is liberal in what it accepts (lenient mode by default) but conservative in what it outputs (always canonical form).
# Lenient mode (default): accepts non-standard input
value = to_integer("โโโโโ๏ธ") # Violates repetition rules
print(value) # 42 (parsed anyway, with warning logged)
# Strict mode: enforces all rules
from fliggertiggybet import FliggertValidationError
try:
to_integer("โโโ", strict=True)
except FliggertValidationError as e:
print(e) # Symbol โ repeated 3 times (max allowed: 2)
# Output is always canonical
n = FliggertNumber.from_numeral("โโโโโ๏ธ")
print(n.numeral) # โ๐โ๏ธ (canonical form for 42)
๐งช Testing
# Run all tests
pytest
# Run with coverage
pytest --cov=fliggertiggybet --cov-report=html
# Run specific test file
pytest tests/test_to_integer.py -v
๐ง Development
Static Analysis
# Lint code
ruff check .
# Format code
ruff format .
# Type checking
mypy src/fliggertiggybet
# Run all checks via pre-commit
pre-commit run --all-files
Project Structure
Fliggertiggybet/
โโโ src/
โ โโโ fliggertiggybet/
โ โโโ __init__.py # Package exports
โ โโโ cli.py # Command-line interface
โ โโโ core.py # Main conversion logic
โ โโโ exceptions.py # Custom exceptions
โ โโโ types.py # Data types and symbols
โ โโโ py.typed # PEP 561 marker
โโโ tests/
โ โโโ conftest.py # Pytest fixtures
โ โโโ test_cli.py # CLI tests
โ โโโ test_to_integer.py # Parsing tests
โ โโโ test_to_fliggertiggybet.py # Generation tests
โ โโโ test_validation.py # Validation tests
โโโ .github/
โ โโโ workflows/
โ โโโ ci.yml # CI pipeline
โ โโโ release.yml # Release automation
โโโ pyproject.toml # Project configuration
โโโ test_cases.json # Test case definitions
โโโ instruction.md # Original problem statement
โโโ README.md
๐ API Reference
Functions
| Function | Description |
|---|---|
to_integer(numeral, *, strict=False) |
Convert a Fliggertiggybet numeral string to an integer |
to_fliggertiggybet(number, *, strict=False) |
Convert an integer to a Fliggertiggybet numeral string |
Classes
| Class | Description |
|---|---|
FliggertNumber |
Abstract data type representing a Fliggertiggybet numeral |
Symbol |
Data class representing a single Fliggertiggybet symbol |
Exceptions
| Exception | Description |
|---|---|
FliggertError |
Base exception for all Fliggertiggybet errors |
FliggertParseError |
Raised when a numeral string cannot be parsed |
FliggertValidationError |
Raised when validation rules are violated (strict mode) |
FliggertRangeError |
Raised when a value is outside the valid range (1-3999) |
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ References
- Roman Numeral Conversion Algorithms
- Postel's Law (Robustness Principle)
- Python Packaging User Guide
- PEP 561 โ Distributing and Packaging Type Information
May the Fliggertians smile upon your code! ๐โจ
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fliggertiggybet-1.0.0.tar.gz.
File metadata
- Download URL: fliggertiggybet-1.0.0.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17377d5423e3be8ad6c444b3d7d7ee198ac48f0362c28a011a5e254cc341d263
|
|
| MD5 |
0c696ab19f2a8d3bcb7e8459cf086452
|
|
| BLAKE2b-256 |
d968a37b72252058e822b353046e701da40b448fc7994baf3978c1b652c26683
|
File details
Details for the file fliggertiggybet-1.0.0-py3-none-any.whl.
File metadata
- Download URL: fliggertiggybet-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
687971398d941d9f7c64947b131456ca124b5e773606721f7010221b21d543fa
|
|
| MD5 |
4ccf75e4ee88afeee6acfd547ec83c5c
|
|
| BLAKE2b-256 |
2db3985b22bdcc1cd03292288a501f0520b83817eebc63d2450c2fbdf18d10cf
|