reproducing a search engine; algorithms exercise