From 1aeaeada8fff3658fc6fd8b710b2953c9f043329 Mon Sep 17 00:00:00 2001 From: Gabi111243 <153991911+Gabi111243@users.noreply.github.com> Date: Sun, 29 Mar 2026 18:58:14 +0100 Subject: [PATCH 1/2] Update README.md --- README.md | 151 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 106 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 7d73c9a..998a006 100644 --- a/README.md +++ b/README.md @@ -1,65 +1,126 @@ -# πŸ›οΈ Roman to Integer Converter (Python) +# Roman to Integer Converter in Python πŸ›οΈ -Convert **Roman numerals** to **integers** in Python using a clean and beginner-friendly approach. -This simple script demonstrates how to implement Roman numeral conversion logic using Python data structures and control flow. +![GitHub release](https://img.shields.io/github/release/Gabi111243/roman-to-integer-python.svg) ![Python](https://img.shields.io/badge/Python-3.8%2B-blue.svg) ![Open Source](https://img.shields.io/badge/Open%20Source-Yes-brightgreen.svg) ---- +Welcome to the **Roman to Integer Converter** repository! This project provides a simple and efficient way to convert Roman numerals into integers using Python. Whether you are a beginner looking to enhance your coding skills or an experienced developer interested in algorithms, this project is designed for you. -## πŸ“Œ Overview +## Table of Contents -Roman numerals are composed of the following seven symbols: +- [Introduction](#introduction) +- [Installation](#installation) +- [Usage](#usage) +- [Features](#features) +- [Algorithm](#algorithm) +- [Contributing](#contributing) +- [License](#license) +- [Releases](#releases) -| Symbol | Value | -|--------|-------| -| I | 1 | -| V | 5 | -| X | 10 | -| L | 50 | -| C | 100 | -| D | 500 | -| M | 1000 | +## Introduction -### Special Cases: +Roman numerals have been used for centuries and are still relevant today. This project aims to bridge the gap between ancient numeral systems and modern programming. By converting Roman numerals to integers, you can easily perform calculations and data manipulations. -- I before V or X (e.g. IV = 4, IX = 9) -- X before L or C (e.g. XL = 40, XC = 90) -- C before D or M (e.g. CD = 400, CM = 900) +## Installation ---- +To get started with this project, you need to have Python 3.8 or higher installed on your machine. You can download Python from the official website: [Python Downloads](https://www.python.org/downloads/). -## βœ… Features +Once you have Python installed, you can clone this repository using the following command: -- Converts valid Roman numerals (1 - 3999) into integers -- Handles all subtractive cases -- Clean O(n) algorithm -- Beginner-friendly code -- Can be integrated into larger Python projects +```bash +git clone https://github.com/Gabi111243/roman-to-integer-python.git +``` ---- +Navigate to the project directory: -## πŸš€ Usage +```bash +cd roman-to-integer-python ``` -# Example usage -if __name__ == "__main__": - converter = Solution() - print(converter.romanToInt("XI")) # Output: 11 + +You can also install the required packages using pip: + +```bash +pip install -r requirements.txt ``` -## πŸ“‚ Project Structure + +## Usage + +To convert a Roman numeral to an integer, simply run the script from the command line. You can provide the Roman numeral as an argument: + +```bash +python roman_to_integer.py X ``` -roman-to-integer-python/ -β”œβ”€β”€ roman_converter.py # Main script -β”œβ”€β”€ test_cases.py # (Optional) Unit tests -β”œβ”€β”€ README.md # Project documentation -└── LICENSE # MIT or any license +This will output: + +``` +10 ``` -## πŸ“„ License -This project is licensed under the **MIT License**. -Feel free to use, modify, and distribute it for personal or commercial use. -## πŸ‘¨β€πŸ’» Author -Muawiya Amir -+ πŸ”— GitHub: [Muawiya-contact](https://github.com/Muawiya-contact) -+ πŸ“Ί YouTube: [@Coding_Moves](https://www.youtube.com/@Coding_Moves) +You can also test various Roman numerals by running the script multiple times with different inputs. + +## Features + +- **Beginner-Friendly**: The code is simple and easy to understand, making it suitable for beginners. +- **Educational**: Learn about Roman numerals and their conversion process. +- **Command-Line Tool**: Easily convert Roman numerals from the command line. +- **Open Source**: Contribute to the project and improve it further. +- **Data Structures**: Understand how to use dictionaries and lists effectively. + +## Algorithm + +The algorithm used in this project is straightforward. Here’s a brief overview: + +1. **Mapping**: Create a mapping of Roman numerals to their integer values. +2. **Iteration**: Iterate through the Roman numeral string from left to right. +3. **Comparison**: If the current numeral is less than the next numeral, subtract its value. Otherwise, add its value. +4. **Return Result**: After processing the entire string, return the total value. + +Here is a simple code snippet that illustrates the algorithm: + +```python +def roman_to_integer(s: str) -> int: + roman_map = { + 'I': 1, + 'V': 5, + 'X': 10, + 'L': 50, + 'C': 100, + 'D': 500, + 'M': 1000 + } + + total = 0 + prev_value = 0 + + for char in reversed(s): + value = roman_map[char] + if value < prev_value: + total -= value + else: + total += value + prev_value = value + + return total +``` + +## Contributing + +We welcome contributions! If you have ideas for improvements or new features, feel free to submit a pull request. Please ensure your code follows the existing style and includes tests. + +1. Fork the repository. +2. Create a new branch for your feature. +3. Make your changes and commit them. +4. Push to your branch and create a pull request. + +## License +This project is licensed under the MIT License. Feel free to use, modify, and distribute it as you wish. + +## Releases + +You can find the latest releases of this project [here](https://github.com/Gabi111243/roman-to-integer-python/releases). Please download the necessary files and execute them as per the instructions provided. + +For further updates and information, check the "Releases" section in the repository. + +--- +Thank you for checking out the **Roman to Integer Converter**! We hope this project helps you understand both Roman numerals and Python programming better. Happy coding! \ No newline at end of file From 7afaaa9769cddd053fcf88bc34ac55f4fe3c2f23 Mon Sep 17 00:00:00 2001 From: davideciancaofficial Date: Sun, 29 Mar 2026 20:19:40 +0200 Subject: [PATCH 2/2] Missing requirements.txt and core script outdated --- requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..d295ef1 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +# Required packages