Skip to content

Instantly share code, notes, and snippets.

@timoteoponce
Created August 1, 2017 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timoteoponce/45d6654fe6ec45a0061c87b1f01bac54 to your computer and use it in GitHub Desktop.
Save timoteoponce/45d6654fe6ec45a0061c87b1f01bac54 to your computer and use it in GitHub Desktop.
word-count-3.md

Word count

TLDR: The program to write must calculate words frequency from a given file.

We will provide you a file with some text on it, and you have to open it and find the frequencies of all words in it having the following requirements:

  • Assume a valid UTF-8 input file
  • All words must be processed in lower case (ignore case) Output must be sorted by word frequency by descendant order
  • Output must have one entry per word, having its frequency next to it

Example input:

Once upon a midnight dreary, while I pondered weak and we ary,
Over many a quaint and curious volume of forgotten lore ....

## Example output:

a 2
and 1 
dreary 1
... 

Resources

Exercise requirements

  • No UI interfaces are required, you can make a command-line application from it (e.g. java -jar myprogram.jar words.txt)
  • Use Java-8 as target environment
  • Do not use assignments, for example, the next kind of code is forbidden
List myList = createList(..); // DO NOT USE THIS, THIS IS FORBIDDEN FOR THIS EXERCISE
  • Create a README.txt file with a short guide for running the code
  • Optional: Use a build tool for the project (Maven or Ant or Gradle)
  • Optional: Create a GIT repository for the project at github.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment