Leon Linhart
12/03/2019, 2:16 PMintersectAllBy
https://github.com/TheMrMilchmann/AdventOfCode2019/blob/f42664c0330b1ba9010c6aac498d79d4fb094489/src/main/kotlin/day03/part2/main.kt#L67Kroppeb
12/03/2019, 2:54 PMLeon Linhart
12/03/2019, 3:03 PMX = {(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.