diff --git a/README.md b/README.md index 39dce6e..657a2f8 100644 --- a/README.md +++ b/README.md @@ -91,3 +91,8 @@ CFcSBwgCCBoHRhkKU1cGAA4AGU5YQR5THBwNFwoGGAxTQQMQVBUSBg4EAAwQRhUQVBUHFAQTGRpT QQM ### bunny-worker-locations * 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. diff --git a/extra/elevator-maintenance/solution.py b/extra/elevator-maintenance/solution.py new file mode 100644 index 0000000..a9e1b91 --- /dev/null +++ b/extra/elevator-maintenance/solution.py @@ -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)