Leap, Difference of Squares, Grains, Collatz Conjecture, Queen Attack, Darts, Hamming, and Space Age completed yesterday. Binary and Linked List completed today. |
||
---|---|---|
.. | ||
.exercism | ||
test-framework | ||
HELP.md | ||
makefile | ||
README.md | ||
test_word_count.c | ||
word_count.c | ||
word_count.h |
Word Count
Welcome to Word Count on Exercism's C 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:
- A number composed of one or more ASCII digits (ie "0" or "1234") OR
- A simple word composed of one or more ASCII letters (ie "a" or "they") OR
- A contraction of two simple words joined by a single apostrophe (ie "it's" or "they're")
When counting words you can assume the following rules:
- The count is case insensitive (ie "You", "you", and "YOU" are 3 uses of the same word)
- The count is unordered; the tests will ignore how words and counts are ordered
- Other than the apostrophe in a contraction all forms of punctuation are ignored
- The words can be separated by any form of whitespace (ie "\t", "\n", " ")
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
- Note that the tests for this exercise expect the output words to be proper C strings. That is, they should be NUL terminated. See https://en.wikipedia.org/wiki/C_string_handling
Source
Created by
- @StevenRoot
Contributed to by
- @bcc32
- @Bulagro
- @ethagnawl
- @Gamecock
- @h-3-0
- @patricksjackson
- @QLaille
- @ryanplusplus
- @sesamemucho
- @ShadowWolf387
- @wolf99
Based on
This is a classic toy problem, but we were reminded of it by seeing it in the Go Tour.