Skip to content

Commit 27acf8e

Browse files
sjwarner-bpFridaTveit
authored andcommitted
parallel-letter-frequency: remove characters with accents / diacritics (exercism#1109)
* parallel-letter-frequency: remove characters with accents / diacritics * parallel-letter-frequency: update README with stretch goal * parallel-letter-frequency: fix readme
1 parent 1cd5cdc commit 27acf8e

3 files changed

Lines changed: 4 additions & 38 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
Single-threaded (non-concurrent) solutions can pass all tests [but the last.](https://www.youtube.com/watch?v=mJZZNHekEQw) Your solution will be tested for concurrency by submitting it as a [Runnable](https://docs.oracle.com/javase/7/docs/api/java/lang/Runnable.html) to an [ExecutorService.](https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ExecutorService.html) Your solution must leverage multiple [Threads](https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html) to pass the final test.
22

33
Java documentation on [parallel streams](https://docs.oracle.com/javase/tutorial/collections/streams/parallelism.html) may provide some help.
4+
5+
As a stretch goal, consider if your implementation will work for characters with [diacritics or accents](https://en.wikipedia.org/wiki/Diacritic). For example, such solutions should not consider e and ë the same character. An example text for this case is [Wilhelmus](https://en.wikipedia.org/wiki/Wilhelmus), the Dutch national anthem.

‎exercises/parallel-letter-frequency/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Single-threaded (non-concurrent) solutions can pass all tests [but the last.](ht
1313

1414
Java documentation on [parallel streams](https://docs.oracle.com/javase/tutorial/collections/streams/parallelism.html) may provide some help.
1515

16+
As a stretch goal, consider if your implementation will work for characters with [diacritics or accents](https://en.wikipedia.org/wiki/Diacritic). For example, such solutions should not consider e and ë the same character. An example text for this case is [Wilhelmus](https://en.wikipedia.org/wiki/Wilhelmus), the Dutch national anthem.
1617

1718
# Running the tests
1819

‎exercises/parallel-letter-frequency/src/test/java/ParallelLetterFrequencyTest.java‎

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,6 @@
88

99
public class ParallelLetterFrequencyTest {
1010

11-
// Poem by Friedrich Schiller. The corresponding music is the European Anthem.
12-
private String OdeAnDieFreude =
13-
"Freude schöner Götterfunken\n" +
14-
"Tochter aus Elysium,\n" +
15-
"Wir betreten feuertrunken,\n" +
16-
"Himmlische, dein Heiligtum!\n" +
17-
"Deine Zauber binden wieder\n" +
18-
"Was die Mode streng geteilt;\n" +
19-
"Alle Menschen werden Brüder,\n" +
20-
"Wo dein sanfter Flügel weilt.";
21-
22-
// Dutch national anthem
23-
private String Wilhelmus =
24-
"Wilhelmus van Nassouwe\n" +
25-
"ben ik, van Duitsen bloed,\n" +
26-
"den vaderland getrouwe\n" +
27-
"blijf ik tot in den dood.\n" +
28-
"Een Prinse van Oranje\n" +
29-
"ben ik, vrij, onverveerd,\n" +
30-
"den Koning van Hispanje\n" +
31-
"heb ik altijd geëerd.";
32-
3311
// American national anthem
3412
private String StarSpangledBanner =
3513
"O say can you see by the dawn's early light,\n" +
@@ -118,7 +96,7 @@ public void manyRepetitionsOfTheSameTextGiveAPredictableResult() {
11896
@Ignore("Remove to run test")
11997
@Test
12098
public void punctuationDoesntCount() {
121-
ParallelLetterFrequency p = new ParallelLetterFrequency(OdeAnDieFreude);
99+
ParallelLetterFrequency p = new ParallelLetterFrequency(StarSpangledBanner);
122100

123101
assertFalse(p.letterCounts().containsKey((int) ','));
124102
}
@@ -131,21 +109,6 @@ public void numbersDontCount() {
131109
assertFalse(p.letterCounts().containsKey((int) '1'));
132110
}
133111

134-
@Ignore("Remove to run test")
135-
@Test
136-
public void allThreeAnthemsTogetherProduceCorrectCounts() {
137-
StringBuilder b = new StringBuilder();
138-
b.append(OdeAnDieFreude);
139-
b.append(Wilhelmus);
140-
b.append(StarSpangledBanner);
141-
142-
ParallelLetterFrequency p = new ParallelLetterFrequency(b.toString());
143-
144-
assertEquals(new Integer(49), p.letterCounts().get((int) 'a'));
145-
assertEquals(new Integer(56), p.letterCounts().get((int) 't'));
146-
assertEquals(new Integer(2), p.letterCounts().get((int) 'ü'));
147-
}
148-
149112
@Ignore("Remove to run test")
150113
@Test
151114
public void multipleThreadsGetUsed()

0 commit comments

Comments
 (0)