DEV Community

Discussion on: Advent of code Day 2 Part 2 Complexity

Collapse
 
craignicol profile image
Craig Nicol (he/him)

I tackled this one last night. For my solution, I created a set of lists where each list contained words that matched on at least 2 of the first 3 characters, some of the lists only containing 1 word, so were eliminated. Then for each list, I found everything that matched the first word on at least 3 of the first 4, sorting non-matches into new lists. I could have been more efficient on subsequent searched by annotating each string with a boolean indicating if it exactly matched the first member of the list so far (and therefore eliminating as soon as 2 characters failed to match), but it did cut down my search space.

Python code for it is here, if you want to tinker : github.com/craignicol/adventofcode...