+ Reply to Thread
Results 1 to 10 of 10

finding the N! routes in excel

  1. #1
    Registered User
    Join Date
    09-30-2007
    Posts
    29

    finding the N! routes in excel

    let say i have six cities.
    A-B-C-D-E-F

    a guy in city A, must visit all other cities and come back to A..

    ABCDEFA
    ABCDFEA
    ABCEDFA
    ABCEFDA
    ABCFDEA
    ABCFEDA

    so that this gives us 120 route.

    is it possible in Excel..

  2. #2
    Forum Expert
    Join Date
    09-09-2005
    Location
    England
    MS-Off Ver
    2007
    Posts
    1,500
    Combin, permut and fact all exist as excel functions, your answer will be using these, to give you a number!

    If you want all the other routes listed you would have to have a macro written to do it, but 120 is a reasonable number to do this for. But from the post I just think you want the number.

    Regards

    Dav

  3. #3
    Registered User
    Join Date
    09-30-2007
    Posts
    29
    i just not want number. i need routes... thanks a lot though

  4. #4
    Forum Expert
    Join Date
    09-09-2005
    Location
    England
    MS-Off Ver
    2007
    Posts
    1,500
    The attached sheet lists them. the macro to do it is contained as well, it is a functional macro, not a pretty one, and im sure the iterations could be reduced if I thought about it a bit more

    Regards

    Dav
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    09-30-2007
    Posts
    29
    tkanks a lot Dav. now i need to think how this work... can you tell me a little what i need to change say 7or 5 city?

  6. #6
    Forum Expert
    Join Date
    09-09-2005
    Location
    England
    MS-Off Ver
    2007
    Posts
    1,500
    I do not have the code in front of me but

    well for 6 cities you need 5 loops as the stat and finish at the sixth

    for 5 cities you would need to loose a loop and for 7 cities add a loop
    you also need to write the information for the extra citiesout in the cells statement and make the condition that selects solutions (countifs of each value in the range) be extented by one. My logic is that if a solution is done, the value will only match with itsself in the countif so for 6 cities (5 variables) this will equal 5, if you cahnged it so 5 cities it will equal 4

    Hopefully you can see the pattern

    Regards

    Dav

  7. #7
    Registered User
    Join Date
    09-30-2007
    Posts
    29
    Thanks Dav. i got you. i will play with it a little

  8. #8
    Registered User
    Join Date
    09-30-2007
    Posts
    29
    hey Dav, hope you read this.

    i did what you have told and i got what i what.
    now i need to add distances between cities. i must add this distance matrix to the VB so that i can find minimum total distance between cities.

    A B C D E F G
    A - 10 5 7 ..........
    B
    C
    D
    E....

    is it possible to do that?
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    09-09-2005
    Location
    England
    MS-Off Ver
    2007
    Posts
    1,500
    There could be a tie to the minimum distance ansi assume you want the route as well. This is just adding the distance to ach route that fits the criteria. sorting it would give you the minimum routes

    Hope that helps

    Regards

    Dav
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    09-30-2007
    Posts
    29
    I really appreciate all of you guys for helping me.
    i bookmarked and will always visit the forum. There are a lot of helpful formulas and so.


    Thanks A Lot

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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