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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:04:46+00:00 2026-05-24T11:04:46+00:00

I have a grid or a 2D array of size N*N. Consider a 6*6

  • 0

I have a grid or a 2D array of size N*N. Consider a 6*6 array like the following for example:

......
......
......
......
......
......

I am given two integers, height and width. The grid will be partitioned into boxes of this size, for example into 3*3 boxes like this:

... ...
... ...
... ...

... ...
... ...
... ...

The same 6*6 grid could be also divided into 2*3 boxes like this:

... ...
... ...

... ...
... ...

... ...
... ...

And so on. One can assume that the two integers given always divide the whole array evenly and neatly as above, if it matters. The problem is then that when I have a coordinate or a index into the array, I need to quickly index the neighbours of this particular coordinate. The neighbours are the points in the same box. For example, if the boxes were of size 2*3, the neighbours of (0,0) would be {(0,1),(0,2),(1,0),(1,1),(1,2)}. This doesn’t seem too difficult, but I am unable to come up with anything even remotely simple. I am using C++, but this is language-independent.

  • 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-24T11:04:47+00:00Added an answer on May 24, 2026 at 11:04 am

    without trying to run this algorithm…

    In pseudocode:

    list_of_points find_neighbours_of(x, y, height_of_box, width_of_box)
    {
        corner_x, corner_y = find_top_left_corner_of_box_containing(x, y)
        iterate over corner_x to corner_x + height_of_box
            iterate over corner_y to corner_y + width_of_box
                if current_x and current_y <> x, y add them to list
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I have an array like this: var grid = Array([1,1,1],[1,0,1],[1,1,1]); And when you
Grid http://www.imagechicken.com/uploads/1264550987064245200.png I have a samegame grid represented by a 1D array of integers.
I have an array of size n^2 representing a square grid of size nxn.
I have a 2d array grid made as int GRID[10][20]; What I want to
I have myself a linear grid of Vector2s stored in a Vector2[,] array, and
I have a grid laid out like so; +---------+---------+ | Image | Details |
We have a grid with red squares on it. Meaning we have an array
Given an array of 81 elements (meant to represent a 9x9 grid) how can
I have grid like this. How to change index for each element, i.e. to
I have a byte array that can be very big in size. I want

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.