exercism/python/word-count
Andreas Zweili 40fc4a37a2 extend the word-count exercise 2021-11-01 19:36:39 +01:00
..
.exercism add a new exercise 2021-10-31 12:52:25 +01:00
HELP.md add a new exercise 2021-10-31 12:52:25 +01:00
README.md add a new exercise 2021-10-31 12:52:25 +01:00
word_count.py extend the word-count exercise 2021-11-01 19:36:39 +01:00
word_count_test.py add a new exercise 2021-10-31 12:52:25 +01:00

README.md

Word Count

Welcome to Word Count on Exercism's Python 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 (ie "0" or "1234") OR
  2. A simple word composed of one or more ASCII letters (ie "a" or "they") OR
  3. 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:

  1. The count is case insensitive (ie "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 (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

Source

Contributed to by

  • @behrtam
  • @c4llmeco4ch
  • @cmccandless
  • @Dog
  • @gabriel376
  • @Grociu
  • @guygastineau
  • @ikhadykin
  • @jackattack24
  • @kytrinyx
  • @lowks
  • @N-Parsons
  • @pheanex
  • @rivergillis
  • @samdec11
  • @sjakobi
  • @tqa236
  • @wobh
  • @yawpitch
  • @ZacharyRSmith

Based on

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