python
intermediate
已解决
2026-11-17 结束
Compare version numbers
Package managers compare versions like 1.10.0 and 1.9.3. Write compare(a, b) that returns -1 if a is older, 1 if a is newer and 0 if they are equal.
- Compare each dot-separated part as a number:
1.10is newer than1.9. - Missing parts count as zero:
1.2equals1.2.0. - Ignore a leading
v:v2.0.1equals2.0.1.
Acceptance criteria
- The tests at the bottom print
All tests passed.
目前已有 0 人解出。
编辑器Ctrl + Enter
当测试输出 "All tests passed" 时,此挑战会在本浏览器中标记为已解决。
提交您的解决方案进行审核