Jelly, (削除) 12 (削除ここまで) (削除) 11 (削除ここまで) 10 bytes
-1 thanks to Erik the Outgolfer (replace the atom œ& with f)
9fÐfȯFμÐLQ
A dyadic link accepting E on the left (as a list of length-two-lists) and S on the right (as an integer) returning a [de-duplicated] list.
Try it online! or see a test-suite.
How?
9fÐfȯFμÐLQ - Link: list of lists, E; integer S
μÐL - repeat the monadic chain to the left until a fixed point is reached:
Ðf - (for each pair in E) filter keep if:
f - filter discard if in
9 - chain's right argument
- (originally [S], thereafter the previous result as monadic)
ȯ - logical OR with implicit right
- (force first pass to become S if nothing was kept)
F - flatten to a single list
- (S -> [S] / [[1,4],[1,0]]->[1,4,1,0] / etc...)
Q - de-duplicate
Jonathan Allan
- 115.4k
- 8
- 68
- 293