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?
Hmm, it's hard to say exactly, since I'm not familiar with the phone game and don't really have time to go through your explanation of it carefully.
But, it looks to me like this problem is probably in the realm of combinatorics or graph theory.
Again, it's hard to say without a bit more care and thought on my end, but you could check out graph theory, because it's actually just super cool generally. Lot of neat results, lot of applications to places you wouldn't expect, cool stuff!
this might be a variant of Towers of Hanoi, and the method for solving these is recursion + tree searching
Key to the Tower of Hanoi - Numberphile