Today's puzzle made me come up with a monster: `in...
# advent-of-code
l
k
I don't understand what it's doing
l
It basically calculates the intersection of an arbitrary number of sets based on part of their elements. (Well that doesn't make it any better, does it? Here, an example using simple math terms:) Let
X = {(A, 1), (A, 2), (B, 1)}
and
Y = {(A, 3), (B, 5), (C, 2)}
Here, obviously no two elements of
X
and
Y
are equal and thus the intersection is empty, but
X.intersectBy(Y) { it.LETTER }
would yield
{(A, 1), (A, 2), (A, 3), (B, 1), (B, 5)}
. At first I thought the second part would require us to deal with more than two wires so I wrote
intersectAll
and
intersectAllBy
to calculate the intersection of an abritrary sequence of sets.