Results 1 to 3 of 3

Thread: Labyrinth

  1. #1
    Join Date
    Nov 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Labyrinth

    Let's say we let a hamster run in a 3-dimensional labyrinth.

    The labyrinth has a certain number of chambers and a certain number of tunnels connecting the chambers. Each tunnel connects two chambers.

    We let the hamster in from one end of the labyrinth and it must come out from the other one.

    All the tunnels are one-way. Also, the chambers and tunnels are positioned, so that the hamster can never go back to a chamber it has already been to.

    The program itself has to count how many possibilities the hamster has to get from the releasing chamber to the chamber with the exit from the labyrinth.

    We know the number of the chambers and we know the number of the tunnels. Every chamber has a number, so the hamster starts from chamber number 1 and ends in the last (the highest) numbered chamber.

    We also know the number data of the tunnels (from which chamber can the hamster move to which chamber).

    For example:
    Chambers: 5
    Tunnels: 6

    Tunnels (A to B):
    1 -> 2
    1 -> 3
    3 -> 4
    4 -> 5
    2 -> 3
    3 -> 5
    What kind of guidelines should I follow while solving the problem?

    Thank you in advance!

  2. #2
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,181
    Thanks
    96
    Thanked 99 Times in 97 Posts

    Default

    This may be someone's homework assignment, but I wouldn't mind a hint too. I have tried for loops, 2d arrays, while loops, a function that looks for all possible combinations, but none do exactly like he is asking for.

    It is really easy to figure out on paper, but for some reason this simple problem is stumping me when I try to write the code for it.
    To choose the lesser of two evils is still to choose evil. My personal site

  3. #3
    Join Date
    Nov 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well, I found out the solution. It does in fact lay in 2-dimensional arrays.

    The topic may be locked now

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
  •