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 7599615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:42:19+00:00 2026-05-30T22:42:19+00:00

I need an algorithm to find out all the possible positions of a group

  • 0

I need an algorithm to find out all the possible positions of a group of pieces in a chessboard. Like finding all the possible combinations of the positions of a number N of pieces.

For example in a chessboard numbered like cartesian coordinate systems any piece would be in a position

(x,y) where 1 <= x <= 8 and 1 <= y <= 8

I’d like to get an algorithm which can calculate for example for 3 pieces all the possible positions of the pieces in the board. But I don’t know how can I get them in any order. I can get all the possible positions of a single piece but I don’t know how to mix them with more pieces.

for(int i = 0; i<= 8; i++){
    for(int j = 0; j<= 8; j++){
        System.out.println("Position: x:"+i+", y:"+j);
    }
}

How can I get a good algoritm to find all the posible positions of the pieces in a chessboard?

Thanks.

  • 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-30T22:42:20+00:00Added an answer on May 30, 2026 at 10:42 pm

    You got 8×8 board, so total of 64 squares.

    Populate a list containing these 64 sqaures [let it be list], and find all of the possibilities recursively: Each step will “guess” one point, and invoke the recursve call to find the other points.

    Pseudo code:

    choose(list,numPieces,sol):
       if (sol.length == numPieces): //base clause: print the possible solution
           print sol
           return
       for each point in list:
           sol.append(point) //append the point to the end of sol
           list.remove(point)
           choose(list,numPieces,sol) //recursive call
           list.add(point)  //clean up environment before next recursive call
           sol.removeLast()
    

    invoke with choose(list,numPieces,[]) where list is the pre-populated list with 64 elements, and numPieces is the pieces you are going to place.

    Note: This solution assumes pieces are not identical, so [(1,2),(2,1)] and [(2,1),(1,2)] are both good different solutions.

    EDIT:

    Just a word about complexity, since there are (n^2)!/(n^2-k)! possible solutions for your problem – and you are looking for all of them, any algorithm will suffer from exponential run time, so trying to invoke it with just 10 pieces, will take ~400 years

    [In the above notation, n is the width and length of the board, and k is the number of pieces]

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

Sidebar

Related Questions

I need to create an algorithm that could find all the critical paths in
I need to implement a Diff algorithm in VB.NET to find the changes between
I need an algorithm which given a list L and a number N ,
I have an algorithm that searches through all of my sites users, finding those
I need to write a program that uses brute-force method to find out how
Given two files containing list of words(around million), We need to find out the
I need an algorithm to determine if a sentence, paragraph or article is negative
I need the algorithm to animate the arrow based on 2 parameters, angle while
I need effective algorithm to keep only ten latest files on disk in particular
I need an algorithm to store a key/value pair, where the key is an

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.