Please Login in order to post a comment
chars = list(input().strip()) print(''.join( sorted( sorted( sorted(chars), key=lambda x: 1-ord(x)%2 if ord(x)//16==3 else ord(x) ), key=lambda x: ord(x)//32, reverse=True )))
s = input() lettersU = [x for x in s if x.isalpha() and x.isupper()] lettersL = [x for x in s if x.isalpha() and x.islower()] numbersO = [x for x in s if x.isnumeric() and int(x)%2 != 0] numbersE = [x for x in s if x.isnumeric() and int(x)%2 == 0] wynik = "".join(sorted(lettersL))+"".join(sorted(lettersU))+"".join(sorted(numbersO))+"".join(sorted(numbersE)) print(wynik)
S = input().strip() low = [] upp = [] even = [] odd = [] for char in sorted(S): if char.isdigit(): (odd if int(char)%2 == 1 else even).append(char) else: (low if char.islower() else upp).append(char) print(''.join(low+upp+odd+even))
import string dict = {k:v for v,k in enumerate(string.ascii_letters + '1357902468')} print(*sorted(input(), key=dict.get), sep='')
A funny solution I came up with:
import re S = input() key = lambda c: ord(c)*1E9 if re.match("[02468]", c) else ord(c)*1E3 if re.match(r"[A-Z]", c) else ord(c)*1E6 if re.match("[13579]", c) else ord(c) print("".join(sorted(S, key=key)))
Seems like cookies are disabled on this browser, please enable them to open this website
A funny solution I came up with: