go to start Ex W9
|home |print view |recent changes |changed November 15, 2017 |
|You are <- set your identity!

Sections: Word Statistics | Wordle visual word cloud Statistics | Prime Numbers | Algorithms |

To speed-up your progress in the C++ exercises and to allow you working more focussed on the implementation instead of setting up Cevelop projects, we have preprared a github repository with scaffolding for this weeks exercises.

The following projects are available:

In order to get those projects you have to clone the following git repository, either within Cevelop (Git Perspective) or with your own git client: https://github.com/PeterSommerlad/CPlusPlusLecture/

The projects are located in the subdirectory exws09 You can import them if you don't already have projects with the same name in your workspace:

Word Statistics ^

Use your class word from ExW5 and use it to create the following simple programs that provide the following results. Remember: your word class ignores case when compared and also ignores punctuation and white space. Empty words are not allowed! Don't program your own loops. Use appropriate data structures but don't store data unnecessarily.

Wordle visual word cloud Statistics ^

Write a program wordle (or derive it from wfavorite) that reads a text from standard input and produces as its output the input for the advanced version of wordle ( http://www.wordle.net/advanced )

Can you suppress fill words like "and", "the", "a" or similar german words that do not add to the meaning of a text. Take a current newspaper article or something to like as input to your program and produce a wordle from it with your program. Compare your wordle to the wordle generated by wordle.net's basic version.

Stop words list
Files with a list of so called stop words for the english and german language, as provided by postgres (/usr/share/postgresql/tsearch_data), are attached below.

Convert the list to initializer list style using the following commands in the VM or unix:
cat german.stop | tr '\n' ' '| sed -r 's|([a-z]+)|"\1",|g'

Prime Numbers ^

Write a program primes that outputs prime numbers. Create a predicate function isPrime(int). Use that predicate to filter a vector filled with numbers from 1 to 100. Don't write your own loops but use the most fitting algorithms from the standard library (i.e., don't use for_each() with a lambda, when there exists a better algorithm.) Can there be a solution for where even isPrime() is not using a hand-written loop?

variants of your program:

Algorithms ^

An introduction into this exercise is given in this weeks video. See self-study part (SsW9).

For using the existing STL algorithms effectively you have to familiarize yourself with available functionality. We have prepared a CUTE test project (algorithm_trivia) with a large set of test cases which require you to insert the correct STL algorithm in order to get the test green. It contains several test suites, each containing some test cases. Usually, those cases fail with the current implementation. We have replaced the original calls with dummy functions (xxx, xxxx, xxxxx, xxxxxx) that satisfy the interface. You don't have to worry about these helper functions. Your task is to fix the test cases by calling the correct STL algorithm (instead of the helper function).

Since there are quite a few algorithms you don't have to solve all algorithms at one. We suggest to solve 2-3 test suites each week. Each suite contains a hint header that lists the algorithms that have to be used in the corresponding suite file. Each algorithm is required once. Read the description of the algorithms first and then try to insert the correct calls. Some algorthims require a predicate. Most of the time we have used an is_prime function that just checks whether the parameter is prime.

Have Fun!

|home |print view |recent changes |changed November 15, 2017 |
|You are <- set your identity!

Ex W9
go to start