Very late myself, here’s mine: https://github.com/dimitarvp/aoc2019.ex/blob/master/lib/day2.ex
Rather naive solution using the for
comprehension with a filter for part two, finishes in ~85ms (milliseconds).
Figured it was slow and added another version with binary search which finishes in ~750us (microseconds), a ~113 times improvement.
Pretty happy with the result, would welcome criticism!
EDIT: DISCLAIMER: Borrowed the pretty neat short variable names from @bjorng’s solution. I liked them a lot and used them.