I
Ioannis Vranos
Peter said:Dear news group,
I have created a small programming challenge for those of you who are
interested in challenging your Standard C++ programming skills. The
challenge is about counting character frequency in large texts,
perhaps useful for spam filtering or classical crypto analysis. You
can read more about it here:
http://blog.p-jansson.com/2009/06/programming-challenge-letter-frequency.html
With kind regards,
Peter Jansson
I think some clarifications should be added to the contest, because the current rules are too vague.
Here are my suggestions, everyone who wishes may try to comply with them.
For Peter Jannson:
1. The code should be compiled with the same C++ compiler. That implies that if C90/95 code is provided, it
should be compilable as C++ code with the relevant casts. It also implies that no C99/C++0x specific features
should be used.
2. The recommended compilation flags are g++ -ansi -pedantic-errors -Wall -O3 -NDEBUG filename.cc -o foobar.
3. Two markings should be taken. An uncached one (e.g. after a reboot), and an OS cached one (after some runs).
For programmers (the initial rules first):
1. Your program should be case insensitive when it counts letters.
2. The program should be written using Standard C++98/03 (C90/95 code can be usually converted to valid C++
code easily, by using casts), so that it can easily be compiled and run on various platforms. This also
permits the code submissions to be tested by Peter Jansson with the same compiler (g++ (C++03)@ubuntu).
3. The code must be absolutely portable, that is to compile and run on all C++03 compilers, without requiring
the installation of additional software/code. This implies e.g. that no other libraries than the standard
library can be used, but for example OpenMP can be used since it works on compilers supporting it and is
ignored on compilers not supporting it (note: I do not know OpenMP).
4. You must begin timing your code just before the text file is opened and you must end the timing after the
results have been written to standard output. For timing, use the style given below:
#incude <ctime> or #include <time.h> (the later mainly for C-style code)
// ...
using namespace std;
// ...
clock_t time 1, time2;
// We start timing.
time1= clock();
// ... Perform the operations
// We "stop" timing.
time2= clock();
// We convert the timing to seconds.
double totalTimeInSeconds= static_cast<double>(time2- time1)/ CLOCKS_PER_SEC;
This works on all platforms (including e.g. Mac OS X), and it will work on the Peter Jansson's testing machine
(g++@Ubuntu Linux), with fractions of seconds accuracy.
5. The timing code should be included in the code submitted.
--
Ioannis A. Vranos
C95 / C++03 Developer
http://www.cpp-software.net