Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5959717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:43:28+00:00 2026-05-22T18:43:28+00:00

Where am I going wrong? This doesn’t seem to work. I’m trying to specify

  • 0

Where am I going wrong? This doesn’t seem to work. I’m trying to specify in the parameter an i and j which locates the cell. And returns the possible values in a 9 x 9 sudoku grid.
What this does it that the first array i.e a[0]= true if the cell is empty and false if its being played or occupied.
the rest of the array consists of values which are possible values that can be inserted into that i and j cell. therefore a possible value is 4 then it will return a[4]= true and the rest of the boolean array would be possible. can anyone tel me where I’m going wrong? Is the while loop incorrect?

   public boolean[] getPossible( int i, int j)
   {

    final int booArraySize = 10;
    boolean[] possibleArray = new boolean[booArraySize];
    int zero = 0;
    if ( game[i][j] == 0)
    {

        for( int b=1; b < possibleArray.length; b++)
        {
            possibleArray[b] = true;
        }

        int row=i;
        int col= 0;

        int[] copyy = new int[GRID_SIZE];
        for( int m = 0; m < copyy.length; m++)
        {
            copyy[m] = 1;
        }

        while ( (copyy[0] < 10) && (copyy[0] >0))
        {
            for ( int q= col+1; q < game.length; q++)
            {
                if( copyy[0] == game[row][q])
                {
                    possibleArray[q] = false;
                }
                else
                {
                    possibleArray[q] = possibleArray[q];
                }
            }
            copyy[0] = copyy[0] + 1;

        }
         possibleArray[0]= true;
    }

    return possibleArray;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:43:29+00:00Added an answer on May 22, 2026 at 6:43 pm

    As I understand it, you are trying to set possibleArray to be true at positions corresponding to allowed values. You seem to be scanning the game board and doing some testing in order to decide when to set each index position to true. I would suggest you reverse your logic: set possibleArray to true for all values and then scan the board for values that would rule out particular values. You can do that by using the value of the game board at each position relevant to (i, j) as an index to set possibleArray to false, as in this pseudocode:

    // initialize possibleArray to true at all positions
    for (each board position u,v along row i, column j, and square containing (i,j)) {
        possibleArray[game[u][v]] = false;
    }
    possibleArray[0] = true; // do this after instead of before
    

    For empty game positions, this will set possibleArray[0] to false, but you fix that after the loop exits.

    EDIT:

    Here’s my attempt to deal with rows and columns simultaneously. It doesn’t deal with the 3×3 box containing position (i,j); that’s left as an exercise. 🙂

    public boolean[] getPossible( int i, int j)
       {
    
        boolean[] possibleArray = new boolean[10];
        if (game[i][j] == 0)
        {
            for( int b=1; b < 10; b++)
            {
                possibleArray[b] = true;
            }
    
            for (int n = 1; n < GRID_SIZE; ++n) {
                possibleArray[game[i][n]] = possibleArray[game[n][j]] = false;
            }
            // TODO Scan the 3x3 square containing cell (i,j)
            possibleArray[0]= true;
        }
        return possibleArray;
    }
    

    I assume (based on your code) that game[1][1] through game[GRID_SIZE][GRID_SIZE] are the right index range for the game board.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This doesn't seem like it should be difficult, but I'm stuck currently. I'm trying
I am trying to rewrite this url and it just doesn't seem to be
I'm sure I'm going about this wrong but I'm trying to write a simple
Any idea where I'm going wrong with this code. I want the TextBox to
Can someone please tell me where I'm going wrong with this piece of code?
I have a question, why doesn't this work? I have an ArrayCollection with data;
Python noob so I might be going about this the wrong way I want
Is my best be going to be a shell script which replaces symlinks with
I can't see where I'm going wrong. I've tried everything I could think of,
I'm having a problem and hope, someone knows what's going wrong and why and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.