Sort by

recency

|

1079 Discussions

|

  • + 0 comments
    string = input()
    ascii = list(chr(i) for i in range(128))
    
    lower = sorted([s for s in string if s in ascii[97:123]])
    upper = sorted([s for s in string if s in ascii[65:91]])
    odd = sorted([s for s in string if s in ascii[48:58] and int(s) % 2 != 0])
    even = sorted([s for s in string if s in ascii[48:58] and int(s) % 2 == 0])
    
    print("".join(lower + upper + odd + even))
    
  • + 0 comments

    def sorting_strings(some_string: str) -> str:

    some_string = list(some_string)   
    some_string.sort(key=lambda x: (x.isdigit(), x.isupper(), x))
    only_numbers = list(filter(lambda x: x.isdigit(), some_string))
    only_letters = list(filter(lambda x: x.isalpha(), some_string))
    odds = list(filter(lambda x: int(x) % 2 == 1, only_numbers))
    evens = list(filter(lambda x: int(x) % 2 == 0, only_numbers))
    

    return ''.join(only_letters+odds+evens)

    if name == 'main': S = input() print(sorting_strings(S))

  • + 0 comments

    import re input_list = str(input()) result_list =""

    pattern1 = re.compile(r'[a-z]') matches = pattern1.findall(input_list) matches=sorted(matches) for i in matches: result_list+=i

    pattern2 = re.compile(r'[A-Z]') matches2 = pattern2.findall(input_list) matches2=sorted(matches2)

    for i in matches2: result_list+=i

    pattern3 = re.compile(r'[0-9]') matches3 = pattern3.findall(input_list) matches3=sorted(matches3) for i in matches3: if int(i) %2!=0: result_list+=i for i in matches3: if int(i) % 2==0: result_list+=i

    print(result_list)

    Solution 2

    import re input_list = str(input()) result_list =""

    pattern = re.compile(r'[a-zA-Z0-9]') matches = pattern.findall(input_list)

    lower_case= sorted([x for x in matches if x.islower()])

    upper_case = sorted([x for x in matches if x.isupper()])

    odd_numeric_case = sorted([x for x in matches if x.isnumeric() and int(x)%2!=0])

    even_numeric_case = sorted([x for x in matches if x.isnumeric() and int(x)%2==0])

    result_list = ''.join(lower_case+upper_case+odd_numeric_case+even_numeric_case) print(result_list)

  • + 0 comments

    Code:

    import re
    S=input()
    small=re.findall("[a-z]",S)
    big=re.findall("[A-Z]",S)
    num=re.findall("[0-9]",S)
    oddnum=[int(n) for n in num if int(n)%2!=0]
    evennum=[int(n) for n in num if int(n)%2==0]    
    print(*(sorted(small)+sorted(big)+sorted(oddnum)+sorted(evennum)),sep='')
    
  • + 0 comments
    x = input()
    lowercase_letters = ''.join(sorted([char for char in x if char.islower()]))
    upper_letters = ''.join(sorted([char for char in x if char.isupper()]))
    odd_digits = ''.join(sorted([char for char in x if char.isdigit() and int(char)%2 != 0]  ))
    even_digits = ''.join(sorted([char for char in x if char.isdigit() and int(char)%2 == 0]  ))
    print( lowercase_letters + upper_letters + odd_digits  + even_digits)