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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:12:23+00:00 2026-06-06T08:12:23+00:00

For example: m_array = new int[6][6]; m_array[0] = new int[]{2, 0, 0, 0, 0,

  • 0

For example:

m_array = new int[6][6];
m_array[0] = new int[]{2, 0, 0, 0, 0, 0};
m_array[1] = new int[]{0, 2, 0, 0, 0, 2};
m_array[2] = new int[]{2, 0, 0, 1, 0, 0};
m_array[3] = new int[]{0, 0, 0, 0, 0, 0};
m_array[4] = new int[]{0, 2, 0, 0, 2, 0};
m_array[5] = new int[]{0, 0, 2, 0, 0, 0};

How can i find the the closest 2 to 1?

i want a function that it return an array path include points of array. For example i will give the “m_array” to my function and it will return to me the nearest 2 for 1, an array path like [2,3][3,4][4,4]

  • 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-06-06T08:12:24+00:00Added an answer on June 6, 2026 at 8:12 am

    These are the things you leave us guessing:

    • there is only one 1, but many 2’s;
    • the path allows diagonal steps;
    • you are looking for the shortest among all paths that connect the 1 with some 2.

    My current thinking is that there is a metric that can be defined for the path length between any two points, so the concepts “a 2 with the shortest path to 1” is equivalent to the concept “the 2 closest to the 1”. The metric can be defined as the number of “rings” around the central 1 one must cross to get to a 2:

    0 0 0
    0 1 0
    0 0 2  --> the 2 is in the first ring
    
    0 0 0 0 0
    0 0 0 0 0
    0 0 1 0 0
    0 0 0 0 0
    0 2 0 0 0 --> the 2 is in the second ring.
    

    If all my assumptions are correct, then you need a function that gives all the members of the first ring, the second ring, and so on, and another function that will search a ring for a 2. Then, finally, you need an algorithm to draw a path to the 2. I hope you realize the path is not unique. A trivial algorithm will move diagonally until aligned (either horizontally or vertically) with the 2 and then continue non-diagonally to the target.

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

Sidebar

Related Questions

I am trying to make a function that can return the prime factors of
Suppose I have an int-array and I want to modify it. I know that
Is the data in std::array<std::array<T,N>, M> guaranteed to be contiguous? For example: #include <array>
I'm stucked with filling an Array dynamic. I can't find the solution. Normal I
Is there an equivalent for ruby's array[n..m] in JavaScript? For example: >> a =
I'm trying to isolate array name and array size from code. This example of
Example routine: const Armature* SceneFile::findArmature(const Str& name){ for (int i = 0; i <
This is my code: SortedDictionary<int,int> Numbers = new SortedDictionary<int,int>(); List<int> onlyP = new List<int>(Numbers.Keys);
I'm trying to build some image algebra code that can work with images (basically
I'd like to create my own class extending array of ints. Is that possible?

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.