miscellaneous code in C++/Python. For fun.