Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
You are given a string S.
S contains alphanumeric characters only.
Your task is to sort the string S in the following manner:
A single line of input contains the string S.
Output the sorted string S.
Sorting1234
ginortS1324
def f(ch):
res = ord(ch)
if 65 <= res <= 90:
res += 100
elif res <= 57:
res += 200
if res % 2 == 0:
res += 10
return res
S = raw_input().strip()
print reduce(lambda x,y: x + y, sorted(S, key=f), '')
def f(c):
code = 0
if c.isupper():
code = 10 ** 3
elif c.isdigit():
code = 10 ** 6
if ord(c) % 2 == 0:
code = 10 ** 9
return code + ord(c)
print(*sorted(input(), key=lambda c: f(c)), sep='')
# Enter your code here. Read input from STDIN. Print output to STDOUT
from string import ascii_lowercase, ascii_uppercase, ascii_letters
sortkey = ascii_letters + "1357902468"
print reduce(lambda x,y: x+y, sorted(raw_input(),key=sortkey.index))
# Enter your code here. Read input from STDIN. Print output to STDOUT
s = sorted(input())
lower = list(filter(lambda x: x.islower(),s))
upper = list(filter(lambda x: x.isupper(),s))
odd = list(filter(lambda x: x.isdigit() and int(x)%2 ==1, s))
even = list (filter(lambda x: x.isdigit() and int(x)%2 ==0,s))
print(*(lower + upper+odd+even), sep = "")
In our experience, we suggest you solve this ginortS Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
ginortS is available on Hacker Rank for Free, if you are stuck anywhere between compilation, just visit Queslers to get all Hacker Rank Solution
I hope this ginortS Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Hacker Rank Problem & Solutions >>
Mini-Max Sum Hacker Rank Solution
String Validators Hacker Rank Solution
Text Alignment Hacker Rank solution