Skip to main content

← DevOps

Compare versions

easy

Read two version numbers like 1.10.2 on two lines. Print -1 if the first is older, 1 if it is newer, 0 if they are the same. Missing parts count as 0 (1.2 equals 1.2.0).

Example 1: input

1.2
1.2.0

Output

0

Example 2: input

1.10.2
1.9.9

Output

1

Plus 2 hidden tests when you check your answer.

Your solution

Read from standard input and print the answer. Run it on the examples as often as you like, then check it against every test.

Stuck?

Open hints one at a time. The write-up explains a full solution.

Discussion

Ask a question or share a tip. Please don’t post full solutions. Posts appear once a moderator approves them.

No posts yet.