Spoiler alert! Contains solutions to questions in the Foobar challenge conducted by Google. Open the compiled solutions for a smooth read of the questions, codes and discussions.
Some additional theoretical discussion of graphs with zero cycles in extended discussion.