This program finds the largest palindromic number between two given numbers.
Note: This program requires Python 3.10 or higher.
A palindromic number (also known as a numeral palindrome) is a number that reads the same forwards and backwards. For example:
- 121 is palindromic because it reads "121" from left to right and right to left
- 1001 is palindromic because it reads "1001" both ways
- 47974 is palindromic because it reads "47974" both ways
Some interesting facts about palindromic numbers:
- Single-digit numbers (0-9) are all palindromic
- The next palindromic after a number is not always the next number (e.g., after 123, the next palindromic is 131)
- They can be even or odd length (like 99 or 101)
- Zero-padded numbers are not considered palindromic (e.g., 0220 is not a valid palindrome)
- Python 3.10 or higher (Python 3.10.x specifically recommended)
- make (optional, for using the Makefile)
If you don't have the correct Python version installed, you can install it using:
make install-python
# Verify installation
python3.10 --versionClone or download this repository
There are two ways to install and run the program:
Create virtual environment and install dependencies
make setupRun the program
make runCreate a virtual environment
python3.10 -m venv venvActivate the virtual environment
source venv/bin/activateInstall dependencies
pip install -r requirements.txtRun the program
python3.10 src/palindromic/palindromic.pyWhen running the program, you'll be prompted to enter two numbers:
- Enter first number
- Enter second number
The program will find the largest palindromic number between these two numbers (exclusive)
Enter first number: 100
Enter second number: 1000
The largest palindromic number between 100 and 1000 is 999If you want to remove the virtual environment and generated files:
make cleanThe test suite includes:
- Unit tests for palindromic validation
- Edge case testing
- Performance tests for large number ranges
To run the test suite:
make test# Activate your virtual environment if not already active
python3.10 -m pytest tests/test_palindromic.py -vThe coverage report will show:
- Percentage of code covered by tests
- Lines that are not covered by tests
- Detailed breakdown of coverage by file
To run tests with code coverage reporting:
make coverage# Activate your virtual environment if not already active
python3.10 -m pytest tests/test_palindromic.py -v --cov=src --cov-report=html:coverage_report --cov-report=term-missing