code: private static void nextDotConstellation(int[] dollarPositions, int[] dotPositions, int nestingLevel) {
          if (nestingLevel == 0) {
              return;
          }
  
          int firstAssignedIdx = 0;
          while (dotPositions[firstAssignedIdx] == -1) {
              firstAssignedIdx++;
          }
  
          if (firstAssignedIdx > 0) {
              dotPositions[firstAssignedIdx] = -1;
              dotPositions[--firstAssignedIdx] = dollarPositions[firstAssignedIdx];
          } else {
              int nofAssigned = 0;
              while (firstAssignedIdx < dotPositions.length && dotPositions[firstAssignedIdx++] != -1) {
                  nofAssigned++;
              }
  
              if (nofAssigned < nestingLevel) {
                  while (firstAssignedIdx < dotPositions.length && dotPositions[firstAssignedIdx] == -1) {
                      firstAssignedIdx++;
                  }
  
                  if (firstAssignedIdx < dotPositions.length && firstAssignedIdx > 0) {
                      dotPositions[firstAssignedIdx] = -1;
                      dotPositions[--firstAssignedIdx] = dollarPositions[firstAssignedIdx];
                  }
              }
          }
      }
docs: If we think of the dotPositions as a binary number (-1 is a "zero", other values represent 1), this basically
  increments this "binary number" in such a way that there are always nestingLevel non-zero values.
  
  The values for non-zeros are taken from the dollarPositions array.
  
  @param dollarPositions the positions of $ in the binary class names
  @param dotPositions the positions of dots to update with a next available "constellation"
  @param nestingLevel the number of $ to replace with .