Problem 44853. Mean number of letters per word (Hard)

Created by HH in Community

The previous problem in this series is 44852.

Given a character array, s, representing a sentence, return a and g, the arithmetic and geometric means, respectively, of the number of letters per word in the given sentence. Round your answer to three decimal digits.

You may make the following assumptions:

1. Not all characters in the array are either letters or spaces. There may also be numeric characters, as well as punctuation.

2. There may be redundant spaces in the sentence.

3. Punctuation does not count as a letter and cannot constitute a word in itself. Numbers also do not count as letters, but can constitute a word.

4. There can be any number of characters and/or words in the sentence, including zero. When there are zero words in the sentence, return empty matrices for a and g.


c = 'The quick brown fox jumps over the lazy dog';
a = 3.889;
g = 3.792


c = 'Another one bites the dust';
a = 4.400;
g = 4.169

Solution Stats

36.36% Correct | 63.64% Incorrect
Last solution submitted on Apr 29, 2019

Recent Solvers4

Suggested Problems

More from this Author34