Implementing Quine's algorithm