HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Strings > problem:


50759 - Text Statistics

Guest
• Discussion of problem (1)

Section problems

• 50908 - Buy 1 Get 1
• 50761 - Magic Words
• 50760 - Hexatridecimal Sum
• 50759 - Text Statistics
• 50246 - Making Potions
• 50258 - String manipulations
• 50264 - String Multiplication
• 50307 - Palindromes
• 50315 - Pig Latin
• 50484 - Number Of Letters
• 50323 - Filtering Contact List
• 50409 - Random Password Generator

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. Difficulty Alpha

Most modern text editors are able to give some statistics about the text they are editing. One nice statistic is the average word length in the text. A word is a maximal continuous sequence of letters ('a'-'z', 'A'-'Z'). Words can be separated by spaces, digits, and punctuation marks. The average word length is the sum of all the words' lengths divided by the total number of words.

For example, in the text "This is div2 easy problem". There are 5 words: "This"is"div"easy" and "problem". The sum of the word lengths is 4+2+3+4+7 = 20, so the average word length is 20/5 = 4.
Given a text, return the average word length in it. If there are no words in the text, return 0.0.

Input
The first line will contain the text of length between 0 and 50 characters inclusive. Text will contain only letters ('a'-'z', 'A'-'Z'), digits ('0'-'9'), spaces, and the following punctuation marks: ',', '.', '?', '!', '-'. The end of text will be marked with symbol '#' (see examples for clarification).
Output
Output should contain one number - the average length. The returned value must be accurate to within a relative or absolute value of 10-9.

Input 1 Input 2 Input 3
This is div2 easy problem.#
a bc#
w84lFC1hD2ot2?43 Jnw67Kmt8KhOQn#
Output 1 Output 2 Output 3
4.0
1.5
2.714285714

Для отправки решений необходимо выполнить вход.

www.contester.ru