changing security protocols, (pfttt..), what the fuck are you doing caleb, writing a sieve over 104 to decrypt blue book encryption for changing security protocols. apparently that code gives a book’s ISBN no (ISBN = 9768198626455), they might have copied it from that book and added some comments.
tree_num is the sum of distinct powers of 3 with natural exponent. we can solve this problem easily if we can realize that any natural number is sum of distinct powers of 2 with natural exponent.
one illustration that any natural number is the sum of distinct powers of 2 with natural exponent is the binary representation of natural numbers. as with natural numbers we can also represent the tree numbers in binary representation and the conversion’s also similar, instead of sum of powers of 2, it is sum of powers of 3.
most of the bugs in the code can easily be removed if we can just assert our visualisation with the code that we wrote. In python it is easy to do it by just printing the data structures using the str or repr methods of those data structures. but when it comes to c++ we had to write these pretty printing routines for c++ stdlib containers(often a very small subset).
later I found some fast IO code snippet(from codechef) which automatically handles the type safety.
after that I have added some modification to it, to enable pretty printing for vector, pair, dictionary.
life has been easier ever since. but the source code got ugly as I always have to append that (wrath of C++) code for every small program, and it is UGLY!!!!!!!
so I thought to convert it into an offline header(as just for debugging)… but then I found this amazing header-only-library(cxx-prettyprint) that allows pretty-printing of any container. and it also supports C++11