Skip to content

2023-4: Like a Version

One common software version numbering scheme is known as "semantic versioning". Typically, semantic versioning uses three numbers representing a major version number, a minor version number, and a build number.

  • The major version is incremented when a new version of the software introduces changes that would make existing applications using the software fail or behave differently.
  • The minor version is incremented when new features are added that didn't previously exist — no pre-existing use of the software will fail in this case.
  • The build number is incremented for bug fixes and similar changes.

Write a function that:

  • takes 3-element integer vector left and right arguments each representing a major version, minor version, and build number.
  • returns
    • ¯1 if the left argument represents a version number older than the right argument
    •  0 if the left argument represents a version number equal to the right argument
    •  1 if the left argument represents a version number newer than the right argument

Hint: The less function < could be helpful in solving this problem.

Examples:

      
      1 2 3 (your_function) 1 2 3
0 

      1 2 3 (your_function) 1 0 9
1

      14 2 11 (your_function) 14 2 12
¯1
your_function ←

Solutions

Video Thumbnail YouTube

Chat transcript Code on GitHub