private static char[] applyError(char[] pattern, ErrorWithIndex error) {
      if (error.error instanceof TypoError typoError) {
        pattern[error.index] = typoError.correctChar;
        return pattern;
      }
      else if (error.error instanceof SwapError) {
        int index = error.index;
        char c = pattern[index];
        pattern[index] = pattern[index + 1];
        pattern[index + 1] = c;
        return pattern;
      }
      else if (error.error instanceof MissError missError) {
        return ArrayUtil.insert(pattern, error.index, missError.missedChar);
      }

      return pattern;
    }
private static char[] applyError(char[] pattern, ErrorWithIndex error)