Remember to print the result in your function.c as the printf part is commented on the partial judge code. |
Robin stumbled arcross split poneglyphs on a ship, but she still couldn't understand the meaning behind them.
Ace, Luffy's brother, came to the ship and noticed the split poneglyphs.
He demonstrated to Robin with his fire fist that by splitting the string into words and sorting the alphabet in each word in decreasing order based on character frequency, a hidden clue could be revealed.
The rules to sort the characters in the string are:
- Sort the characters by how frequently they appear in the string. If they appear more frequently, they should come first.
- If the frequency of characters is the same, sort it by the type, namely from uppercases > lowercases > digits.
- If the type is also the same, sort uppercase and lowercase characters in dictionary order, and sort digits in increasing order.
Take the string "IxyzamxyzluffyxyzaAbb54xyztree" for example. If it were to be split using the delimiter "xyz", the set of words from the splitting process is ["I", "am", "luffy", "aAbb54", "tree"].
After sorting each alphabet in the words, we obtain ['I', 'am', 'ffluy','bbAa45', 'eert'].
Explanation:
"aAbb54" -> "bbAa45"
'b' appears twice while 'a', 'A', '5', and '4' appear once. So 'b' must appear before 'a', 'A', '5', and '4'. Next, since the order of precedence is uppercase letters > lowercase letters > digits, 'A' must appear before 'a', '5', and '4', and 'a' must appear before '5' and '4'. Finally since '5' and '4' have the same frequency then sort it by increasing order.
"tree" -> "eert"
'e' appears twice while 'r' and 't' both appear once. So 'e' must appear before both 'r' and 't'. And 'r' is before 't' since it is like so in dictionary order
ps: you should print by yourself at the sort function
The first line contains a string S that should be split, 20 ≤ the length of S ≤ 499
The second line is the delimiter string P, 1 ≤ the length of P ≤ 9.
Output the sorted strings splited by the given pattern.
Don't forget to include '\n' at the end of each output string.