I feel like you’re overthinking this. In pseudocode this this just:
UnitsFreeInB = ContainerSize - UnitsInB
UnitsToSend = min(min(1, UnitsInA), UnitsFreeInB)
UnitstInA = max(0, UnitsInA - UnitsToSend)
I feel like you’re overthinking this. In pseudocode this this just:
UnitsFreeInB = ContainerSize - UnitsInB
UnitsToSend = min(min(1, UnitsInA), UnitsFreeInB)
UnitstInA = max(0, UnitsInA - UnitsToSend)