tags:

views:

12

answers:

0

Ive a hashset, which produces the possible number for each cell in the grid

public void PotentialMoves(int i, int j,int []puzzle) 
{ 
    Set<Integer> all = new HashSet<Integer>();



    for (int n= 0; n< 9; n++)
        all.add(new Integer(n+1));

    if (puzzle[j * 9 + i] != 0)return;

    Set<Integer> used = new HashSet<Integer>(); 

    for (int row = 0; row < 9; row++)

        if (puzzle[row * 9 + i] != 0) used.add(puzzle[row * 9 + i]);

    for (int col = 0; col < 9; col++)
        if (puzzle[j * 9 + col] != 0)
            used.add(puzzle[j * 9 + col]);

    int minR = (i/3) * 3;   
    int minC = (j/3) * 3;   

    for (int row = minR; row < minR + 3; row++)
        for (int col = minC; col < minC + 3; col++)

            if (puzzle[row * 9 + col] != 0)
                used.add(puzzle[row * 9 + col]);
    Set<Integer> moves = new HashSet<Integer>(all);
    moves.removeAll(used);


}

when the grid is loaded up for each cell with out a number, when the tracker ball is pressed on the phone i want a keypad to come up with the possible numbers in, how would i go about doing this with using the hashset?