+ Reply to Thread
Results 1 to 6 of 6

Finding shortest path between two points

  1. #1
    Registered User
    Join Date
    09-04-2019
    Location
    Studenec, Czech Republic
    MS-Off Ver
    2016
    Posts
    3

    Finding shortest path between two points

    Hey, so I'm working on a simulation project and I've encountered an obstacle.

    Here's a representation of the problem:

    Výstřižek.PNG

    I want to find a path from A to C (or C to A, doesn't really matter), that's as short as possible. The W's represent walls, that cannot be crossed. Also, the path can't be diagonal, only ortogonal.
    I've been trying to come up with a solution, but no luck so far.

    Is this even possible to do?

    Thanks for any advice. Have a nice day.
    Petr

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Finding shortest path between two points

    I wrote an exhaustive recursive function to find the shortest path:

    Please Login or Register  to view this content.
    See attached. If you want to see it in action, comment out the line which turns off screen updating.

    WBD
    Attached Files Attached Files
    Office 365 on Windows 11, looking for rep!

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,213

    Re: Finding shortest path between two points

    This is going to be an interesting one...Wanna see how this plays out...
    Does the letter W always represent a brick in a wall...Is the markers always A and C or are other letters in the alphabet used...
    How must the path be displayed...Interior cell color changes...step by step cell reference etc etc
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  4. #4
    Registered User
    Join Date
    09-04-2019
    Location
    Studenec, Czech Republic
    MS-Off Ver
    2016
    Posts
    3

    Re: Finding shortest path between two points

    Wow, thanks a lot. I will look into it. Much appreciated!

  5. #5
    Registered User
    Join Date
    09-04-2019
    Location
    Studenec, Czech Republic
    MS-Off Ver
    2016
    Posts
    3

    Re: Finding shortest path between two points

    Hey, yeah, the W is like a brick, impassable. Letters A and C are just an example, it could be any letter.

    Regarding how the path is going to be displayed and the other things... I really don't know either. I am just assisting the main programmer who works on this project, as a summer job before school starts. He basically just told me he wants to find a shortest path between two cells and that's it. I'll probably tell you more when i see him again.

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,213

    Re: Finding shortest path between two points

    Just for the fun of it...Would fall apart if the maze was more elaborate though...
    Please Login or Register  to view this content.
    Just for interest sake...I have attached a file I found on the net...
    The left area [A:L] allows you to enter 1 into a cell to create an amazing elaborate maze...
    The right area [O:Y] depicts the path...
    Attached Files Attached Files
    Last edited by sintek; 09-05-2019 at 04:39 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. calculating shortest distance between two points
    By captainq in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-12-2019, 08:57 AM
  2. Shortest Path Between Cells (VBA)
    By basschmidt in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-18-2018, 06:07 PM
  3. Shortest Path Optimization
    By excelcombinations in forum Excel General
    Replies: 2
    Last Post: 09-15-2017, 08:58 AM
  4. Shortest Path between Locations (without repeating)
    By ciaran3 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-05-2017, 10:43 AM
  5. VBA that calculates the shortest path
    By den_1985 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-05-2016, 05:58 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1