exercism-rust/word-count
2023-08-21 13:50:14 -04:00
..
.exercism init commit 2023-08-21 13:50:14 -04:00
src init commit 2023-08-21 13:50:14 -04:00
tests init commit 2023-08-21 13:50:14 -04:00
.gitignore init commit 2023-08-21 13:50:14 -04:00
Cargo.toml init commit 2023-08-21 13:50:14 -04:00
HELP.md init commit 2023-08-21 13:50:14 -04:00
README.md init commit 2023-08-21 13:50:14 -04:00

Word Count

Welcome to Word Count on Exercism's Rust Track. If you need help running the tests or submitting your code, check out HELP.md.

Instructions

Given a phrase, count the occurrences of each word in that phrase.

For the purposes of this exercise you can expect that a word will always be one of:

  1. A number composed of one or more ASCII digits (i.e. "0" or "1234") OR
  2. A simple word composed of one or more ASCII letters (i.e. "a" or "they") OR
  3. A contraction of two simple words joined by a single apostrophe (i.e. "it's" or "they're")

When counting words you can assume the following rules:

  1. The count is case insensitive (i.e. "You", "you", and "YOU" are 3 uses of the same word)
  2. The count is unordered; the tests will ignore how words and counts are ordered
  3. Other than the apostrophe in a contraction all forms of punctuation are ignored
  4. The words can be separated by any form of whitespace (i.e. "\t", "\n", " "), or external punctuation.

For example, for the phrase "That's the password: 'PASSWORD 123'!", cried the Special Agent.\nSo I fled. the count would be:

that's: 1
the: 2
password: 2
123: 1
cried: 1
special: 1
agent: 1
so: 1
i: 1
fled: 1

For the phrase "one,two,three" the count would be:

one: 1
two: 1
three: 1

Source

Created by

  • @EduardoBautista

Contributed to by

  • @andrewclarkson
  • @ashleygwilliams
  • @AvasDream
  • @ClashTheBunny
  • @coriolinus
  • @cwhakes
  • @EduardoBautista
  • @efx
  • @ErikSchierboom
  • @IanWhitney
  • @ijanos
  • @jonmcalder
  • @kytrinyx
  • @lutostag
  • @mkantor
  • @navossoc
  • @nfiles
  • @petertseng
  • @pminten
  • @rofrol
  • @stringparser
  • @xakon
  • @yawpitch
  • @ZapAnton

Based on

This is a classic toy problem, but we were reminded of it by seeing it in the Go Tour.