Solving day1 and day2 part two #18
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Day 1
Easily adjust the algorithm to compare against seen result. To save time, iterate over right list and store results in a map to make future lookups
O(1).Day 2
Implement a tolerance variable that can handle finding a violation. The trick was how to determine if the input set can handle removing a value. This was implemented with a recursive call, removing one from the tolerance and one element from the original input. Lots of simple unit tests were added to make this process easier to reason about.