sehe
  • Member for 10 years, 8 months
  • Last seen more than a month ago
Read CSV and use bidirectional BFS to find the shortest connections between actors
14 votes

It looks like you found a pretty nice approach there already. A few general things stand out: Using globals Magical constants and unsafe C-style arrays/raw pointers: static vector<uint64_t> *...

View answer
C++ code to generate random DAGs
Accepted answer
10 votes

Important errors: your random isn't random (seed it) your random isn't uniform (use uniform distributions rather than just taking the modulus, which will skew the distribution) precede is often ...

View answer
Stopwatch that uses the abstract factory design pattern
Accepted answer
8 votes

Okay, after I worked my way through the original code, a few things have become clearer. Since I have never done programming with ncurses I was eager to try my hand at a better design. Here it comes. ...

View answer
Stopwatch that uses the abstract factory design pattern
8 votes

A few random notes. I don't like the mix between "object oriented" and "procedural" here. If a Digit is supposed to "have a" position, then in no way should it be incrementing the y of that ...

View answer
Printing stars using nested loops
8 votes

Edit Oh well, not using nested for... Sorry about that int inc = 2; for (int i = 1; i >= 1; i += inc){ std::cout<<std::string(i,'*')<<endl; if ( i == 5 ) inc = -2; }

View answer
Euler problem c++ / std::library usage
Accepted answer
7 votes

Your conversions are... pretty WTF :) void insert_if_product(string const& factor1, string const& factor2, string const& product) { auto p = std::stoul(product); if (std::stoul(...

View answer
Testing new C++11 features with Hangman
7 votes

Here's my inline edits. The most conspicuous result is less manual work 20%-25% shorter (in lines, words, and characters). Less code means less bugs and less maintenance burden (if not obfuscating) ...

View answer
Boost.Spirit UTF-8 string literal parser with escape support
Accepted answer
6 votes

3. The error handlers The problem with the throw expression, as the compiler kindly reminded you, is that they're void-expressions. Even if it compiled, it would not do what you want: it'd throw ...

View answer
Using Boost.Spirit to transform expression to AST
Accepted answer
3 votes

I'll narrate this in the order I "discover" your code. Then I'll present some tweaks which I think mattered the most in the end. I'm liking a lot of what you've done. A few names could (...

View answer
Disable execution of parts of the code based on user's choice C++
Accepted answer
3 votes

I see two things: option acquisition (a lot of control flow and ad-hoc checks to detect the user input) operational program flow (the decisions based on it). Here I'd suggest Null Object pattern ...

View answer
Standard deviation from iterators
Accepted answer
3 votes

Firstly, make it correct. N is integral, you could make it E so you don't accidentally do integer arithmetic. N-1 is wrong. Rename average to mean. Don't hardcode E. You get: template <...

View answer
Boost::range::for_each + functor
3 votes

I would suggest to factor the code differently. In fact, you're transforming collection 1 (Persons in vec) into a map of (name, rank) where rank is somehow calculated from the age of a person. I'd ...

View answer
C++ delegate implementation with member functions
Accepted answer
3 votes

Fatal bugs: A big issue is the fact that you take a copy of the object in the function in this line: std::function < void (Class, Params...) > f = func; This needs to be Class& at ...

View answer
Most efficient way in C++ to strip strings
3 votes

Use the C locale. On some locales, isalpha and friends might be very slow. E.g. on UNIX LANG=C export LANG or use std::locale to activate the C locale from code std::locale::global(std::locale::...

View answer
C++ implementation of depth-first search
2 votes

You have received excellent feedback from others. I can only add to that in a show-and-tell fashion. What my version does is address all the issues mentioned by others: make the directed/undirected ...

View answer
Use of a single member struct as an attribute with boost::spirit::karma generators
Accepted answer
2 votes

Here's what I'd do: Live On Coliru #include <string> #include <vector> struct foo_struct { std::vector<int> bar_vector; foo_struct(std::vector<int> v = {}) : ...

View answer