Jump to content

Word frequency: Difference between revisions

m
added highlighting and whitespace, added periods to some end-of-sentences in the task preamble.
m (C - return value of g_mapped_file_get_contents isn't guaranteed to be zero-terminated)
m (added highlighting and whitespace, added periods to some end-of-sentences in the task preamble.)
Line 3:
 
;Task:
Given a text file and an integer   '''n''',   print/display the   '''n'''   most
common words in the file   (and the number of their occurrences)   in decreasing frequency.
their occurrences) in decreasing frequency.
 
For the purposes of this task:
* A word is a sequence of one or more contiguous letters.
* You are free to define what a letter is.   Underscores, accented letters, apostrophes, and other special characters can be handled at the example writer's discretion.   For example, you may treat a compound word like "well-dressed" as either one word or two.   The word "it's" could also be one or two words as you see fit.   You may also choose not to support non US-ASCII characters.   Feel free to explicitly state the thoughts behind the program decisions.
* Assume words will not span multiple lines.
* Do not worry about normalization of word spelling differences.   Treat "color" and "colour" as two distinct words.
* Uppercase letters are considered equivalent to their lowercase counterparts.
* Words of equal frequency can be listed in any order.
 
 
Cookies help us deliver our services. By using our services, you agree to our use of cookies.