    public void open(int iOne, int jOne) {
        checkInput(iOne, jOne);
        int i = iOne - 1;
        int j = jOne - 1;
        int index = getIndex(i, j);
        if (!grid[index]) {
            grid[index] = true;
            int n; 
            boolean hasN = false;
            for (int d = 0; d < 4; d++) {
                n = getNeighborIndex(i, j, d);
                if (-1 != n && isOpen(n)) {
                    uf.union(index, n);
                    hasN = true;
                }
            }
            if (0 == i) {
                uf.union(index, topIndex);
            }
            if (hasN) {
                for (int b = gridSize-1; b >= gridSize-rowLen; b--) {
                    if (isOpen(b) && uf.connected(topIndex, b)) {
                        uf.union(b, bottomIndex);
                        break;
                    }
                }
            }
        }
    }

    public void open(int iOne, int jOne) {
        checkInput(iOne, jOne);
        int i = iOne - 1;
        int j = jOne - 1;
        int index = getIndex(i, j);
        if (!grid[index]) {
            grid[index] = true;
            int n; 
            boolean hasN = false;
            for (int d = 0; d < 4; d++) {
                n = getNeighborIndex(i, j, d);
                if (-1 != n && isOpen(n)) {
                    uf.union(index, n);
                    hasN = true;
                }
            }
            if (0 == i) {
                uf.union(index, topIndex);
            }
            if (hasN) {
                for (int b = gridSize-1; b >= gridSize-rowLen; b--) {
                    if (isOpen(b) && uf.connected(topIndex, b)) {
                        uf.union(b, bottomIndex);
                        break;
                    }
                }
            } else if (1 == gridSize) {
                uf.union(index, bottomIndex);
            }
        }
    }
