7 kyu

Simple Fun #48: Higher Version

273 of 358myjinxin2015

Description:

Task

Given two version strings composed of several non-negative decimal fields separated by periods ("."), both strings contain equal number of numeric fields.

Return true if the first version is higher than the second version and false otherwise.

The syntax follows the regular semver ordering rules:

1.0.5 < 1.1.0 < 1.1.5 < 1.1.10 < 1.2.0 < 1.2.2
        < 1.2.10 < 1.10.2 < 2.0.0 < 10.0.0

There are no leading zeros in any of the numeric fields, i.e. you do not have to handle inputs like 100.020.003 (it would instead be given as 100.20.3).

Example

For ver1 = "1.2.2" and ver2 = "1.2.0", the output should be true;

For ver1 = "1.0.5" and ver2 = "1.1.0", the output should be false.

Input/Output

  • [input] string ver1

  • [input] string ver2

  • [output] a boolean value

Puzzles

Stats:

CreatedJan 25, 2017
PublishedJan 25, 2017
Warriors Trained549
Total Skips6
Total Code Submissions1515
Total Times Completed358
JavaScript Completions273
C# Completions90
Total Stars4
% of votes with a positive feedback rating94% of 114
Total "Very Satisfied" Votes101
Total "Somewhat Satisfied" Votes12
Total "Not Satisfied" Votes1
Total Rank Assessments6
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • kazk Avatar
  • hobovsky Avatar
Ad