Simple Fun #185: Revamp
Description:
Task
Consider a string of lowercase Latin letters and space characters (" ").
First, rearrange the letters in each word alphabetically
.
And then rearrange the words in ascending order of the sum of their characters' ASCII
values.
If two or more words have the same ASCII
value, rearrange them by their length in ascending order; If their length still equals to each other, rearrange them alphabetically
.
Finally, return the result.
Example
For s = "batman is bruce wayne"
, the result should be "is bceru aenwy aamntb"
.
After rearranging the letters the string turns into "aamntb is bceru aenwy". The ASCII values of each word are: [627, 220, 529, 548]. After sorting the words the following string is obtained: "is bceru aenwy aamntb" (with ASCII values of [220, 529, 548, 627]).
For s = "peter parker is spiderman"
, the result should be "is eeprt aekprr adeimnprs"
(ASCII values: [220, 554, 645, 963])
Input/Output
[input]
strings
A string of lowercase words. Each word is separated by exactly one space character.
[output]
a string
Similar Kata:
Stats:
Created | Mar 6, 2017 |
Published | Mar 6, 2017 |
Warriors Trained | 606 |
Total Skips | 28 |
Total Code Submissions | 2598 |
Total Times Completed | 324 |
JavaScript Completions | 106 |
C# Completions | 48 |
PHP Completions | 42 |
Python Completions | 154 |
Total Stars | 16 |
% of votes with a positive feedback rating | 96% of 130 |
Total "Very Satisfied" Votes | 121 |
Total "Somewhat Satisfied" Votes | 8 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 7 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |