[Tutor] lambdas, generators, and the like

Keith Winston keithwins at gmail.com
Fri Jan 17 07:06:19 CET 2014


On Thu, Jan 16, 2014 at 5:44 AM, spir <denis.spir at gmail.com> wrote:
> This, in addition to the requirement of uniqueness which as you say is
> probably best met using a set (after filter). This may lead to you chosing
> to store, even if otherwise not truely necessary. An question is: what kind
> of data are combinations, and how do you compare them? If there is a
> possibly cheap shortcut by comparing only a little bit of combination data,
> then you may make a set of those little bits only and avoid storing the
> whole of combinations.


Hmmm. My guess is you're reaching for a teachable moment here... I
ended up leaving this entire approach behind, for what I think is your
point: I can simply iterate through the combinations and test them
before I even get to the next one. Sadly, this didn't nearly address
my problem, which I think is that my solution set is still ending up
N^2 time on a rather large data set. Danny offered a different
approach entirely, which I haven't implemented. I THINK that I
optimized this approach by not using any lists, testing iterations as
they were generated, changing my data order so I generate shorter
combinations first, and I STILL couldn't get past something like the
first 3 coins out of 8. It's all good, I learned a lot in the process.

-- 
Keith


More information about the Tutor mailing list