finish extra/elevator-maintenance

Submitting solution...
Submission: SUCCESSFUL. Completed in: 37 mins, 56 secs.
This commit is contained in:
Seongbeom Park 2022-05-09 07:04:23 +09:00
parent 9ff2b6eea9
commit dcf52e5f53
2 changed files with 20 additions and 0 deletions

View File

@ -91,3 +91,8 @@ CFcSBwgCCBoHRhkKU1cGAA4AGU5YQR5THBwNFwoGGAxTQQMQVBUSBg4EAAwQRhUQVBUHFAQTGRpT QQM
### bunny-worker-locations ### bunny-worker-locations
* Completed in: 6 mins, 49 secs. * Completed in: 6 mins, 49 secs.
### elevator-maintenance
* Completed in: 37 mins, 56 secs.
* Feedback
> [elevator-maintenance] Sample output of the test cases in readme.txt for python language is not match with the return type. Changing first output from `0.1,1.1.1,1.2,1.2.1,1.11,2,2.0,2.0.0` to `["0.1", "1.1.1", "1.2", "1.2.1", "1.11", "2", "2.0", "2.0.0"]` and changing second output from `1.0,1.0.2,1.0.12,1.1.2,1.3.3` to `["1.0", "1.0.2", "1.0.12", "1.1.2", "1.3.3"]` would be great.

View File

@ -0,0 +1,15 @@
def solution(l):
return sorted(l, key=compare)
import re
def compare(ver_str):
return tuple([int(v) for v in re.split(r'\.', ver_str)])
tests = [
(["1.11", "2.0.0", "1.2", "2", "0.1", "1.2.1", "1.1.1", "2.0"], ["0.1", "1.1.1", "1.2", "1.2.1", "1.11", "2", "2.0", "2.0.0"]),
(["1.1.2", "1.0", "1.3.3", "1.0.12", "1.0.2"], ["1.0", "1.0.2", "1.0.12", "1.1.2", "1.3.3"]),
]
for i, o in tests:
result = solution(i)
print (i, result == o, result, o)