-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathginortS.py
More file actions
42 lines (28 loc) · 1.03 KB
/
ginortS.py
File metadata and controls
42 lines (28 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
You are given a string S.
S contains alphanumeric characters only.
Your task is to sort the string S in the following manner:
All sorted lowercase letters are ahead of uppercase letters.
All sorted uppercase letters are ahead of digits.
All sorted odd digits are ahead of sorted even digits.
Input Format
A single line of input contains the string S.
Constraints
0 < len(S) < 100
Output Format
Output the sorted string S.
Sample Input
Sorting1234
Sample Output
ginortS1324
Note:
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 one sorted function in your code. A 0 score will be awarded for using sorted more than once.
Hint: Success is not the key, but key is success.
Problem's link: https://www.hackerrank.com/challenges/ginorts/forum
"""
from __future__ import print_function
S = raw_input().strip()
order = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1357902468'
sorted_S = sorted(S, key=order.index)
print(*sorted_S, sep='')