Cody

Problem 45434. Weighted Names

A cell is given which contains several names. You've to return those names sorted by their weight.

Weight is to be calculated by the following rules -

 1.each letter's weight is the ASCII value. 
 2.the 1st name weights 2 times its original value but if the name contains any middle name 
   then the middle name would weight 2x while 1st name would weight 3x.
   The family name will always weight 1x.
 3. Some of the names might contain some prefix like Col, Prof, Hon etc. They would weight
   10 times their 1st letter. [each letter is not to be weighted for this case]
 4. Again some of the names might also contain some suffix.

For example,

Ser Arthur Dayne
 Here, 'Ser' is a prefix. so value = 83*10 = 830.  [ASCII value of 'S' is 83]
       'Dayne' is the family name. so value = 497*1 = 497
       'Arthur' is the 1st name.   so value = 630*2 = 1260
 So total value= 830 + 497 + 1260 = 2587.

Solution Stats

75.0% Correct | 25.0% Incorrect
Last Solution submitted on Jun 10, 2020

Problem Comments

Problem Recent Solvers3

Suggested Problems

More from this Author145

Problem Tags