finish extra/elevator-maintenance #21
@ -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.
|
||||||
|
|||||||
15
extra/elevator-maintenance/solution.py
Normal file
15
extra/elevator-maintenance/solution.py
Normal 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)
|
||||||
Loading…
x
Reference in New Issue
Block a user