From: Erik Veenstra Date: 2008-03-19T08:20:48+09:00 Subject: Re: Food Database (#159) I've combined 3 of my own libraries, which resulted in a 30 minutes solution for this quiz. The 3 parts are: * Hash#nearest instead of Hash#[] * Caching the result of an already parsed data file * Indexing of a data file of lines Combine these parts into one sentence: "How can we find the best matching key in a cached index of a data file?" Which was pretty much the task of the quiz in one sentence... I'll explain my solution bottom-up, which roughly means: the opposite of the order in which the code executes. By the way, here're the timings. Searching for the food "QUINOA,CKD". All runs result in the same output. "quinoa,ckd "Exact key, not cached 0m1.078s "quinoa,ckd "Exact key, cached 0m0.081s "quinoa "Partial key, cached 0m0.159s "qinoa "Partial key with typo, cached 0m0.179s The Code + Explanation: http://dark-code.bulix.org/srih9o-65866 gegroet, Erik V. - http://www.erikveen.dds.nl/