Skip to main content

A Python library for parsing and generating Fliggertiggybet numerals - an emoji-based numeral system

Project description

Fliggertiggybet ๐ŸŽ†

CI Python Version License: MIT

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

  1. Additive Notation: Symbols are written largest to smallest, left to right, and their values are added.

    • Example: ๐Ÿ™Œโœ‹๐Ÿ‘Œ = 50 + 10 + 5 = 65
  2. 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)
  3. Repetition Limits:

    • โ˜๏ธ, โœŒ๏ธ, ๐Ÿ‘Œ, ๐Ÿ™Œ, ๐ŸŽŠ โ€” maximum 1 consecutive
    • โœ‹, ๐Ÿ’ฏ โ€” maximum 2 consecutive
    • ๐ŸŽ† โ€” maximum 3 consecutive
  4. 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


May the Fliggertians smile upon your code! ๐ŸŽ†โœจ

Project details


Download files

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

Source Distribution

fliggertiggybet-1.0.0.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

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

fliggertiggybet-1.0.0-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

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

Hashes for fliggertiggybet-1.0.0.tar.gz
Algorithm Hash digest
SHA256 17377d5423e3be8ad6c444b3d7d7ee198ac48f0362c28a011a5e254cc341d263
MD5 0c696ab19f2a8d3bcb7e8459cf086452
BLAKE2b-256 d968a37b72252058e822b353046e701da40b448fc7994baf3978c1b652c26683

See more details on using hashes here.

File details

Details for the file fliggertiggybet-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fliggertiggybet-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 687971398d941d9f7c64947b131456ca124b5e773606721f7010221b21d543fa
MD5 4ccf75e4ee88afeee6acfd547ec83c5c
BLAKE2b-256 2db3985b22bdcc1cd03292288a501f0520b83817eebc63d2450c2fbdf18d10cf

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