Skip to content

ozgunlu/nano-roman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nano-roman

PyPI License Size CI

World’s tiniest Roman ↔ Decimal number converter — ~1 KB, zero deps. Single-file, CLI included. Perfect for code-golf, minimal containers, or just for fun.


✨ Features

  • int → ROMAN and ROMAN → int (case-insensitive)
  • ✅ Standard subtractive forms: IV, IX, XL, XC, CD, CM
  • ✅ Classic 1–3999 supported; >3999 continues with repeated M
  • ✅ Zero dependencies, single tiny file
  • ✅ CLI: nano-roman

🚀 Usage

# Local (from repo)
python app_min.py 3999   # MMMCMXCIX
python app_min.py XL     # 40

After installing:

# CLI
pip install nano-roman
nano-roman 1984   # -> MCMLXXXIV
nano-roman XLII   # -> 42
nano-roman mmxxv  # -> 2025

🤓 Why so small?

  • Minimal token table (S and V) + greedy subtractive matching
  • No heavy parsing/regex trees, no dependencies
  • Single module + tiny CLI wrapper

🎉 Fun Ideas

  • Convert the current year
(Get-Date -Format yyyy) | % { nano-roman $_ }   # 2025 -> MMXXV
date +%Y | xargs nano-roman                     # 2025 -> MMXXV
  • “Roman clock” (hour only)
  (Get-Date -Format HH) | % { nano-roman $_ }     # 14 -> XIV
date +%I | xargs nano-roman                     # 07 -> VII
  • Git tag in Roman
git tag "v$(nano-roman 2025)" && git push origin "v$(nano-roman 2025)"
  • Batch convert a list
printf "4\n9\n42\n1999\n" | while read n; do nano-roman "$n"; done
# IV, IX, XLII, MCMXCIX
  • Quick Windows alias
Set-Alias r nano-roman
r 3999   # -> MMMCMXCIX

Notes

  • Classical Roman numerals have no zero and no negative values.
  • For values >3999, this tool renders repeated M (ASCII extension). Classical notation would use overlines (vinculum) or parentheses ×1000.

📜 License

MIT © 2025