Skip to content

pablozizzutti/palindromicNumberFinder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Palindromic Number Finder

This program finds the largest palindromic number between two given numbers.

Note: This program requires Python 3.10 or higher.

What is a Palindromic Number?

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)

Prerequisites

  • 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 --version

Installation

Clone or download this repository

There are two ways to install and run the program:

Using make (recommended)

Create virtual environment and install dependencies

make setup

Run the program

make run

Manually

Create a virtual environment

python3.10 -m venv venv

Activate the virtual environment

source venv/bin/activate

Install dependencies

pip install -r requirements.txt

Run the program

python3.10 src/palindromic/palindromic.py

Usage

When 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)

Example

Enter first number: 100
Enter second number: 1000
The largest palindromic number between 100 and 1000 is 999

Cleanup

If you want to remove the virtual environment and generated files:

make clean

Running Tests

The test suite includes:

  • Unit tests for palindromic validation
  • Edge case testing
  • Performance tests for large number ranges

To run the test suite:

Using make

make test

Manually

# Activate your virtual environment if not already active
python3.10 -m pytest tests/test_palindromic.py -v

Code Coverage

The 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:

Using make

make coverage

Manually

# 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

About

Finds the largest palindromic number between two given numbers (exclusive)

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors