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

  • Home
  • SEARCH
  • 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 6926905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:58:43+00:00 2026-05-27T10:58:43+00:00

I am having an issue seeing the errors with this. I am using TextPad4.7.3

  • 0

I am having an issue seeing the errors with this. I am using TextPad4.7.3 and when i try to do a board 53×53 or larger the errors that i can see are at

else if (move[1][m] > 0 && move[1][m] < 9){

if(tour(movNum + 1, (x + movCol[move[0][m]]), (y + movRow[move[0][m]]), bSize, board)){

break;}}

Since this is a recursive program, I doubt that this line is the real issue. The error list is so long that I cannot see the top where it would point out the real position of the error. Anyone know of anything that can properly log my errors or a method to see the error. Or if someone knows why when i use a number 53 or larger that this gives me a huge list of errors instead of continuing to work? This was an assignment, but at this point I am just trying to fix it for my own self satisfaction. Any help would be appreciated.

-WBM

import java.util.Scanner;
public class Tour {

// Knight moves
    static int movCol[] = { 1,  2, 2, 1, -1, -2, -2, -1};
    static int movRow[] = {-2, -1, 1, 2,  2,  1, -1, -2};

// Main method
    static public void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.print("What are the board's Dimentions?");
        int bSize = scan.nextInt();
        int board[][] = new int[bSize][bSize];
        System.out.print("Start on what column?");
        int positionY = scan.nextInt();
        System.out.print("Start on what row?");
        int positionX = scan.nextInt();
        System.out.println();
        for (int i = 0; i < bSize; i=i+1) {
            for (int j = 0; j < bSize; j=j+1) {
                board[i][j] = -1;
            }
        }
        tour(0, positionX - 1, positionY - 1, bSize, board);
    }



    static void printBoard(int board[][]) {
        for(int i = 0; i < board.length; i=i+1){
            for(int j = 0; j < board[0].length; j=j+1){
                if (board.length < 11){
                    System.out.printf("%3d", board[i][j]);
                }
                else if (board.length < 32){
                    System.out.printf("%4d", board[i][j]);
                }
                else if (board.length < 101){
                    System.out.printf("%5d", board[i][j]);
                }
                else if (board.length < 317){
                    System.out.printf("%6d", board[i][j]);
                }
                else if (board.length < 1001){
                    System.out.printf("%7d", board[i][j]);
                }
                else if (board.length < 3163){
                    System.out.printf("%8d", board[i][j]);
                }
                else if (board.length < 10001){
                    System.out.printf("%9d", board[i][j]);
                }
            }
            System.out.println("\n");
        }
    }

    static boolean tour(int movNum, int x, int y, int bSize, int board[][]) {
        boolean success = true;
        board[x][y] = movNum;
        if((movNum < ((bSize * bSize) - 1))){
            int move[][] = new int[2][8];
            for(int i = 0; i < 8; i=i+1){
                if((x + movCol[i]) >= 0 && (x + movCol[i]) < bSize && (y + movRow[i]) >= 0 && (y + movRow[i]) < bSize){
                    if(board[x + movCol[i]][y + movRow[i]] < 0){
                        move[0][i] = i;  // marks all possible moves
                        for(int h=0; h<8; h=h+1){

                            if((x + movCol[i] + movCol[h]) >= 0 && (x + movCol[i] + movCol[h]) < bSize && (y + movRow[i] + movRow[h]) >= 0 && (y + movRow[i] + movRow[h]) < bSize){

                                if(board[x + movCol[i] + movCol[h]][y + movRow[i] + movRow[h]] < 0){

                                    move[1][i] = move[1][i] + 1;
                                }
                            }
                        }
                    }
                    else {
                        move[0][i] = i;  
                        move[1][i] = 9;
                    }
                }
                else {
                    move[0][i] = i;  
                    move[1][i] = 9;
                }
            }
            for(int j = 0; j < 7; j=j+1){      
                for(int k = 0; k < 7; k=k+1){
                    if (move[1][k]> move[1][k+1]){
                        int lower = move[1][k+1];
                        int lower2 = move[0][k+1];
                        int upper = move[1][k];
                        int upper2 = move[0][k];
                        move[1][k] = lower;
                        move[0][k] = lower2;
                        move[1][k+1] = upper;
                        move[0][k+1] = upper2;
                    }
                }
            }

            for(int m = 0; m < 8; m=m+1){
                if (move[1][m] == 0 && movNum == ((bSize * bSize) - 2)){

                    if(tour(movNum + 1, (x + movCol[move[0][m]]), (y + movRow[move[0][m]]), bSize, board)){
                        break;
                    }
                }
                else if (move[1][m] > 0 && move[1][m] < 9){

                    if(tour(movNum + 1, (x + movCol[move[0][m]]), (y + movRow[move[0][m]]), bSize, board)){
                        break;
                    }
                }
            }
            success = false;   
            board[x][y] = -1;  
        }
        else{
            printBoard(board);      
            System.out.println("\n");
            System.exit(0);
        }
        return success;
    }
}
  • 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-27T10:58:44+00:00Added an answer on May 27, 2026 at 10:58 am

    Sounds like it’s probably a StackOverflowError. The Windows console has a preferences dialog associated with it. Use those preferences to set the “scroll buffer” to 4000 lines (instead of the default which is like 12 or something.) Then you’ll be able to scroll up and see what the error message actually is.

    Assuming that it is indeed a stack overflow problem, one of the recursive calls is probably being made without an appropriate exit condition; examine them carefully. There’s an if block around the two recursive calls, but both the calls have exactly the same arguments; that suggests to me that maybe there’s a typo there?

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

Sidebar

Related Questions

I am using Oracle SQL Developer, but I am having an issue seeing results
Having an issue here that I have tried everything I can think of but
I'm having an issue with a query that currently uses LEFT JOIN weblog_data AS
I'm having an issue with a standard ASP.NET page that has a TextBox and
I am having an issue similar to this question: Problem with WCF and Multiple
I'm having a bizarre issue that I haven't seen before and I'm thinking it
having a strange issue, must be something I'm just not seeing. I set up
After spending several hours today searching and seeing several people having the same issue,
I'm having an issue in my application where I am seeing an excessive amount
I keep having complaints that users are logged in as each other. They can

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.