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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:21:28+00:00 2026-05-13T20:21:28+00:00

I got a grid with two points. I want to calculate the amount squares

  • 0

I got a grid with two points. I want to calculate the amount squares each point can reach before the other. Currently I implement a FloodFill-Algoritm, which can calculate the amount of squares one point can reach.

How can I change that algorithm to do the “flooding” for both points simaltaneuosly or at least one after another?

  • 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-13T20:21:29+00:00Added an answer on May 13, 2026 at 8:21 pm

    What do you mean by “each point can reach before the other”?

    It looks to me like you need a BF search. Use a FIFO queue like so:

    Let p1 and p2 be the positions of the two points.

    let f be the first element in the queue and l the last. Initially f = 0, l = 1. Let Q be the queue.

    Q[f] = p1
    Q[l] = p2
    while ( f <= l )
    {
       poz = Q[f];
       ++f;
    
       for each neighbour poz' of poz
          if poz' hasn't been marked yet
          {
             mark poz'
             add poz' to Q: Q[++l] = poz
          }
    }
    

    Q will need to be the size of your grid (rows x cols). You can use two matrices: one with the positions p1 can reach and the other with the positions p2 can reach, or you can use one matrix and mark the squares p1 reaches with positive numbers and the squares p2 reaches with negative numbers. If you are interested where they meet, you just need to check if you are about to mark a positive value from a negative value (poz negative and poz’ positive) or the other way around. This will basically do your flooding in turns: flood one square from p1, then from p2, then from p1, then from p2 and so on.

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

Sidebar

Related Questions

Got a grid with some numeric columns and it's need to implement for each
I've got a grid view. I want it to say you have nothing to
I've got a vey simple form with a grid of 16 labels, each of
Ive got a problem - in my grid I linked two combobox (country and
I'm battling with this assignment :) I've got two classes: Ocean and Grid. When
In my application got one sidebar, which is holding this two component : <Grid
I've got a grid of pictures that I want to be able to drag/drop
I've got a grid, currently with three columns. The first column contains a WrapPanel.
I've got a grid (dojox.grid v1.2) that I don't want to be sortable. How
I've got a Grid with some scale transform applied; the Grid contains an image:

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.