Write a program called no_vowels.pl that will count
how many words DO NOT have an 'a' or an 'A',
how many DO NOT have an 'e' or an 'E',
how many DO NOT have an 'i' or an
'I', and so on.
The output should look like the below.
Note that the letters must be listed in decreasing order of frequency
14000 words do not have an 'u'
11258 words do not have an 'o'
10123 words do not have an 'i'
11523 words do not have an 'a'
10111 words do not have an 'e'
Name:
Anonymous2011-06-10 20:36
Someone please optimize this, I suck at programming.
for(size_t i = 0; i < ncores; ++i)
total += totals[i];
for(std::set< std::pair<size_t, char> >::iterator it = ms.begin(); it != ms.end(); ++it)
std::cout << (total - it->first) << " words do not have '" << it->second << "'\n";
}
>Someone please optimize this, I suck at programming.
Yeah, don't use C++ io streams, they are slow as fuck!, there's like several virtual calls per fucking character read from a file plus 2 or 3 fucking buffers things get copied into. The solution is either to use C style fopen/fread/etc. which is better, but the optimal solution is to use your operating system's file IO facilities, like the POSIX open/read/write calls or Windows OpenFile, ReadFile, etc. and just wrap it in a thin C++ class with no virtual functions.
Also, boost's threads implementation is slow and unoptimized because boost programmers are lazy as fuck like you. Use a C++0x/C++11 threads implementation, which has the same interfaces, but is more optimized.
>>60 It's actually a fairly functional language. But yeah, it's probably going nowhere, like most of my petty projects ;_;
Well, today it's hard to advance new language, without backing at Microsoft (Haskell) or Google (Python).
>>81
Hmm I just realized you can pass extra parameters directly to boost.thread without using boost.bind.
>>83
Yes I just discovered how slow they are. I wrote the LineReader class after trying to do the whole thing with streams and wondering why it was so butt-fucking-slow.
Name:
Anonymous2011-06-10 22:15
</code>
sub print_vowels {
my %vowels = @_;
foreach (sort { $vowels{$a} <=> $vowels{$b} } keys %vowels) {
print "$_ was not in $vowels{$_} words\n";
}
}
my %vowels;
while (<>) {
chomp;
my @words = split " ", $_;
foreach (@words) {
$vowels{a}++ if (/^[^Aa]*$/);
$vowels{e}++ if (/^[^Ee]*$/);
$vowels{i}++ if (/^[^Ii]*$/);
$vowels{o}++ if (/^[^Oo]*$/);
$vowels{u}++ if (/^[^Uu]*$/);
}
print_vowels %vowels;
}
</code>