Skip to content

Commit 46dd3c4

Browse files
kytrinyxkotp
authored andcommitted
Sync word-count docs with problem-specifications
The word-count exercise has been overhauled as part of a project to make practice exercises more consistent and friendly. For more context, please see the discussion in the forum, as well as the pull request that updated the exercise in the problem-specifications repository: - https://forum.exercism.org/t/new-project-making-practice-exercises-more-consistent-and-human-across-exercism/3943 - exercism/problem-specifications#2247
1 parent 14ad763 commit 46dd3c4

File tree

2 files changed

+42
-18
lines changed

2 files changed

+42
-18
lines changed
Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,47 @@
11
# Instructions
22

3-
Given a phrase, count the occurrences of each _word_ in that phrase.
3+
Your task is to count how many times each word occurs in a subtitle of a drama.
44

5-
For the purposes of this exercise you can expect that a _word_ will always be one of:
5+
The subtitles from these dramas use only ASCII characters.
66

7-
1. A _number_ composed of one or more ASCII digits (ie "0" or "1234") OR
8-
2. A _simple word_ composed of one or more ASCII letters (ie "a" or "they") OR
9-
3. A _contraction_ of two _simple words_ joined by a single apostrophe (ie "it's" or "they're")
7+
The characters often speak in casual English, using contractions like _they're_ or _it's_.
8+
Though these contractions come from two words (e.g. _we are_), the contraction (_we're_) is considered a single word.
109

11-
When counting words you can assume the following rules:
10+
Words can be separated by any form of punctuation (e.g. ":", "!", or "?") or whitespace (e.g. "\t", "\n", or " ").
11+
The only punctuation that does not separate words is the apostrophe in contractions.
1212

13-
1. The count is _case insensitive_ (ie "You", "you", and "YOU" are 3 uses of the same word)
14-
2. The count is _unordered_; the tests will ignore how words and counts are ordered
15-
3. Other than the apostrophe in a _contraction_ all forms of _punctuation_ are ignored
16-
4. The words can be separated by _any_ form of whitespace (ie "\t", "\n", " ")
13+
Numbers are considered words.
14+
If the subtitles say _It costs 100 dollars._ then _100_ will be its own word.
1715

18-
For example, for the phrase `"That's the password: 'PASSWORD 123'!", cried the Special Agent.\nSo I fled.` the count would be:
16+
Words are case insensitive.
17+
For example, the word _you_ occurs three times in the following sentence:
18+
19+
> You come back, you hear me? DO YOU HEAR ME?
20+
21+
The ordering of the word counts in the results doesn't matter.
22+
23+
Here's an example that incorporates several of the elements discussed above:
24+
25+
- simple words
26+
- contractions
27+
- numbers
28+
- case insensitive words
29+
- punctuation (including apostrophes) to separate words
30+
- different forms of whitespace to separate words
31+
32+
`"That's the password: 'PASSWORD 123'!", cried the Special Agent.\nSo I fled.`
33+
34+
The mapping for this subtitle would be:
1935

2036
```text
21-
that's: 1
22-
the: 2
23-
password: 2
2437
123: 1
25-
cried: 1
26-
special: 1
2738
agent: 1
28-
so: 1
29-
i: 1
39+
cried: 1
3040
fled: 1
41+
i: 1
42+
password: 2
43+
so: 1
44+
special: 1
45+
that's: 1
46+
the: 2
3147
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Introduction
2+
3+
You teach English as a foreign language to high school students.
4+
5+
You've decided to base your entire curriculum on TV shows.
6+
You need to analyze which words are used, and how often they're repeated.
7+
8+
This will let you choose the simplest shows to start with, and to gradually increase the difficulty as time passes.

0 commit comments

Comments
 (0)