I feel like this has to be a math/logic thing that has a name already and I wanna know what it’s called so I can look it up when I’m no longer extremely drunk.

In this phone game the objective is to get all the people on all the same color floors with as few stops at any floor as possible. When the last few moves look like this, you just have to go through in the right order and only stop at each stop once (except the first/last floor).

But sometimes there’s different little sub-sets of pairs inside the bigger set of pairs that are self-contained, and for each one of those there’s another floor that has to be started and stopped on to complete that loop. That makes the minimum number of moves to solve: the sum of the number of pairs in both sub-sets together plus the number of subsets. (And only counting the number of pairs in both subsets because if one of the pairs is already matched it won’t count for the moves).

So like these two are all one big continuous loop: A-E, B-A, C-B, D-C, E-D and A-B, B-E, C-A, D-C, E-D

And this one has one already matched leaving a single complete loop in need of matching: A-B, B-E, C-A, D-D, E-C

These ones, however, have two loops. one loop that’s three floors long (four moves) and one that’s two floors long (three moves): A-B, B-C, C-A, D-E, E-D and A-D, B-E, C-A, D-C, E-B

And these ones have one already matched pair, and two sub-sets of two that still need to be matched: A-B, B-A, C-C, D-E, E-D and A-D, B-B, C-E, D-A, E-C

What is this called?