• + 5 comments

    Found an interesting bug(or feature?):

    When I tried to solve the problem using the following code it gives me Wrong answer

    Code (Python 3), Verdict: Wrong Answer

    s = input()
    s_sorted = sorted(s,key = lambda x:(x.isdigit() and int(x)%2==0, x.isdigit(),x.isupper(),x.islower(),x))
    print(*(s_sorted),sep = '')
    

    Like the problem said:

     a) Using join, for or while anywhere in your code, even as substrings, will result in a score of 0. b) You can only use sorted function in your code. A 0 score will be awarded for using sorted more than once.

    But in the above code I did not use join, for or while. Also I did not use sorted() more than once!

    What I realized later that it is counting the variable s_sorted as sorted() function. So, I removed _sorted and it got Accepted.

    Code (Python 3), Verdict: Accepted

    s = input()
    s = sorted(s,key = lambda x:(x.isdigit() and int(x)%2==0, x.isdigit(),x.isupper(),x.islower(),x))
    print(*(s),sep = '')
    

    Funny, right? :D