Tinkering with various algorithms in C++