public static Integer[] graySuccessor(Integer[] e) {
        Integer[] copy = Arrays.copyOf(e, e.length);
        if (hammingDist(copy) % 2 == 0) {
            copy[0] = 1 - copy[0];
            return copy;
        } else {
            for (int i = 0; i <= e.length - 2; i++) {
                if (copy[i] != 0) {
                    copy[i + 1] = 1 - copy[i + 1];
                    return copy;
                }
            }
        }
        return null;
    }