6 kyu

Simple Fun #185: Revamp

154 of 324myjinxin2015

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] string s

A string of lowercase words. Each word is separated by exactly one space character.

  • [output] a string
Fundamentals

Stats:

CreatedMar 6, 2017
PublishedMar 6, 2017
Warriors Trained606
Total Skips28
Total Code Submissions2598
Total Times Completed324
JavaScript Completions106
C# Completions48
PHP Completions42
Python Completions154
Total Stars16
% of votes with a positive feedback rating96% of 130
Total "Very Satisfied" Votes121
Total "Somewhat Satisfied" Votes8
Total "Not Satisfied" Votes1
Total Rank Assessments7
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • ZozoFouchtra Avatar
  • donaldsebleung Avatar
  • hobovsky Avatar
  • saudiGuy Avatar
Ad