Skip to main content

Compare version strings

None

Project description

Ormuco and VanHack Code Challenge

The Question The goal of this question is to write a software library that accepts 2 version string as input and returns whether one is greater than, equal, or less than the other. As an example: “1.2” is greater than “1.1”. Please provide all test cases you could think of.

My Solution

Get Started:

  • Clone this repository:
$ git@github.com:jattoabdul/compare_version_strings.git
  • Change into the compare_version_strings directory:
$ cd compare_version_strings
  • Install all dependencies:
$ pip install -r requirements.txt

Run Test:

$ pytest

Run as Packaged Library:

  • Install:
$ pip install jatto_compare_version_strings
  • Usage:
from compare_version_strings.compare_version_strings import compare_versions, prepare_comparison_result

comparison_result = compare_versions('1.0.0.2.9', '1.0.0.3.4')

# It will return:
#     A positive number: If the first version is greater than the second  
#     A negative number: If the first version is smaller than the second
#     Zero: If the versions are equals

formated_result = prepare_comparison_result('1.0.0.2.9', '1.0.0.3.4')

# It will return:
#     '{version1}' is equal to '{version2}': If the comparison returns 0
#     '{version1}' is smaller than '{version2}': If the comparison returns -1
#     '{version1}' is greater than '{version2}': If the comparison returns 1

Project details

None

Download files

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

Source Distribution

jatto_compare_version_strings-0.0.1.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page