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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:26:27+00:00 2026-06-04T11:26:27+00:00

The mini-program is supposed to print out all the possible routes through a maze,

  • 0

The mini-program is supposed to print out all the possible routes through a maze, where the entrance/starting point is always one down from the top left corner and all possible exits that are always on the right wall. It retrieves the maze from a text file.

The maze is actually just a bunch of text.
The maze consists of an n x n grid, consisting of “#” symbols that are walls, and assorted letters [a…z] representing the walkable area/paths. Letters can repeat but can never be side by side.

The maze is 15×15.

An uppercase S always labels the entrance, and is on the left wall in the second highest spot. A possible path is only through letters- you can’t walk on # symbols. Any letter on the right wall represents exit(s).

For example,

######
Sa#hln
#bdp##
##e#ko
#gfij#
######

is a possible maze. My little program is supposed to print out all the possible routes after reading the text file that actually contains the maze.

A call to the program would generate the following output to the screen:

Path 1: S,a,b,d,e,f,i,j,k,o
Path 2: S,a,b,d,p,h,l,n
2 total paths

How about would I go about doing this? I don’t need a complete code answer, I just want some guidance on how to approach this problem.

So far I’ve done everything except the actual algorithm itself that recursively checks adajcent squares to see if you can walk on them, and I don’t know how I’d work on multiple paths.

This is what I have so far (I know my pathcheck is wrong, but I didn’t know what else to do):

    #include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
#include <cstdio>
using namespace std;

ifstream file("maze.txt");
vector<char> vec(istreambuf_iterator<char>(file), (istreambuf_iterator<char>())); // Imports characters from file
vector<char> path;                      // Declares path as the vector storing the characters from the file
int x = 18;                             // Declaring x as 18 so I can use it with recursion below
char entrance = vec.at(16);             // 'S', the entrance to the maze
char firstsquare = vec.at(17);          // For the first walkable square next to the entrance
vector<char> visited;                   // Squares that we've walked over already

int main()
{
    if (file) {
        path.push_back(entrance);               // Store 'S', the entrance character, into vector 'path'
        path.push_back(firstsquare);            // Store the character of the square to the right of the entrance
                                                // into vector 'path'.

        while (isalpha(vec.at(x)))
        {
            path.push_back(vec.at(x));
            x++;
        }

        cout << "Path is: ";                    // Printing to screen the first part of our statement

        // This loop to print to the screen all the contents of the vector 'path'.
        for(vector<char>::const_iterator i = path.begin(); i != path.end(); ++i)  // 
        {
        std::cout << *i << ' ';
        }

        cout << endl;
        system ("pause");                       // Keeps the black box that pops up, open, so we can see results.
        return 0;
        }
}

Thanks!

  • 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-04T11:26:29+00:00Added an answer on June 4, 2026 at 11:26 am

    You need a few things to start:

    1. A way of representing the maze in memory — a “data structure” that’s appropriate for a grid like a maze
    2. Methods for accessing and manipulating that maze
    3. A method of rendering the maze — perhaps to print out a maze
    4. A way of tracking your progress
    5. An algorithm for solving the problem at hand

    Consider starting with a much smaller maze — perhaps one that’s 3×3 in size — with a path that goes straight across the map. Your program should be able to solve that. Then change the path to curve a bit. Then make the map bigger. Make the path harder. Have some “red herring” branches off the path.

    A smaller map, increasing in complexity, should make debugging the effort a lot easier. (And if you don’t know how to use a debugger, having a small problem to start will make learning the debugger easier.)

    Good luck!

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

Sidebar

Related Questions

I've written some code which is a mini simple imitation of messenger program. In
I'm attempting to write a short mini-program in Python that plays around with force-based
I am starting an FTP session using: C:\Program Files\FTP Server\msftpsrvr.exe -start Now I want
At work one of our target platforms is a resource constrained mini-server running Linux
I'm making a mini ORM for a Java program I'm writing... there is a
My company uses one build machine (a Mac Mini) as a CI node to
I was added jackson-mini-1.9.2.jar(is not jackson-all-1.9.2.jar) in my project, I want to convert json
For a mini project I am making a quiz program My current (relavant) code
Just picked up one of these ARM Cortex-M3 LPC1768 mini boards from eBay. It's
Like Mini Jappix but without the big application server behind. Is there one ?

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.