title: How do I solve a maze if I was not giving the starting(source) point and exit point?
body: <p>I am trying to solve a maze homework that provides a different maze for testing. The maze changes in size and does not provide me with the starting position(s) or exit(e) like in other examples I have seen in stackoverflow. I need help in how to choose the starting point from the provided string by converting it possibly into a 2d array and that way solve the maze. Thanks</p>
  
  <p>This is what I have tried so far</p>
  
  <pre><code>#include "solve.h"
  #include "vertex.h"
  
  
  //char** read_maze(string maze, int* rows, int* columns)
  //{
  //  for (int i = 0; i &lt; maze.length; i++)
  //  {
  //
  //  }
  //  char** mymaze = new char*[*rows];
  //
  //  for (int x = 0; x &lt; *rows; x++)
  //      mymaze[x] = new char[*columns];
  //
  //  for (int i = 0; i &lt; *rows; i++)
  //      for (int j = 0; j &lt; *columns; j++)
  //          mymaze[i][j] = 1;
  //
  //  return mymaze;
  //}
  
  string solve(string maze)
  {
      //find coordinate of starting node!
      int rows = 1, columns = 1;
      char** mymaze;
      mymaze = read_maze(maze, &amp;rows, &amp;columns);
  
  
  
      unordered_map&lt;string, Vertex*&gt; vertexSet;
      unordered_map&lt;Vertex*, Vertex*&gt; breadCrumbs;
  
  
  
      //breadthFirstSearch(maze);
  
      string output = "";
      //Vertex* current = t;
      /*while (current != s)
      {
          output = current-&gt;col + current-&gt;row + " " + output;
          current = breadCrumbs[current];
      }*/
      output = maze + " " + output;
  
      return output;
  }
  
  void breadthFirstSearch(string maze, Vertex* s)
  {
      queue&lt;Vertex*&gt; Q;
      unordered_set&lt;Vertex*&gt; marked;
  
      //Vertex* s = vertexSet[];
  
      marked.insert(s);
      Q.push(s);
  
      while (!Q.empty())
      {
          Vertex* current = Q.front();
          Q.pop();
  
          for (int i = 0; i &lt; current-&gt;neighs.size(); i++)
          {
              Vertex* y = current-&gt;neighs[i];
              if (marked.find(y) == marked.end())
              {
                  marked.insert(y);
                  Q.push(y);
  
              //  breadCrumbs[y] = current;
              } 
          }
      }
  }
  
  ``````````````````````
  
  This are the provided files for testing !
  main.cpp
  ````````````
  #include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;string&gt;
  #include "solve.h"
  
  using namespace std;
  
  inline void _test(const char* expression, const char* file, int line)
  {
      cerr &lt;&lt; "test(" &lt;&lt; expression &lt;&lt; ") failed in file " &lt;&lt; file;
      cerr &lt;&lt; ", line " &lt;&lt; line &lt;&lt; "." &lt;&lt; endl;
      abort();
  }
  
  #define test(EXPRESSION) ((EXPRESSION) ? (void)0 : _test(#EXPRESSION, __FILE__, __LINE__))
  
  
  int main()
  {
      // Setup
      srand(2018 + 'f');
      string maze, soln;
  
  
      maze = "";
      maze += "##### #\n";
      maze += "#     #\n";
      maze += "# #####\n";
      soln = "";
      soln += "#####o#\n";
      soln += "#ooooo#\n";
      soln += "#o#####\n";
      test(solve(maze) == soln);
  
      maze = "";
      maze += "##### #\n";
      maze += "#   # #\n";
      maze += "# # # #\n";
      maze += "# #   #\n";
      maze += "# #####\n";
      soln = "";
      soln += "#####o#\n";
      soln += "#ooo#o#\n";
      soln += "#o#o#o#\n";
      soln += "#o#ooo#\n";
      soln += "#o#####\n";
      test(solve(maze) == soln);
  
      maze = "";
      maze += "########\n";
      maze += "#      #\n";
      maze += "# ## ###\n";
      maze += "#      #\n";
      maze += "## ## ##\n";
      maze += "#  ##  #\n";
      maze += "## ### #\n";
      maze += "## ### #\n";
      soln = "";
      soln += "########\n";
      soln += "#      #\n";
      soln += "# ## ###\n";
      soln += "# oooo #\n";
      soln += "##o##o##\n";
      soln += "# o##oo#\n";
      soln += "##o###o#\n";
      soln += "##o###o#\n";
      test(solve(maze) == soln);
  
      maze = "";
      maze += "########\n";
      maze += "#  #    \n";
      maze += "# ## ###\n";
      maze += "#      #\n";
      maze += "# # # ##\n";
      maze += "# ###  #\n";
      maze += "#  ### #\n";
      maze += "## #####\n";
      soln = "";
      soln += "########\n";
      soln += "#  #oooo\n";
      soln += "# ##o###\n";
      soln += "#oooo  #\n";
      soln += "#o# # ##\n";
      soln += "#o###  #\n";
      soln += "#oo### #\n";
      soln += "##o#####\n";
      test(solve(maze) == soln);
  
      maze = "";
      maze += "# ######\n";
      maze += "#  #   #\n";
      maze += "# ## ###\n";
      maze += "#      #\n";
      maze += "# # # ##\n";
      maze += "# ###  #\n";
      maze += "#  ###  \n";
      maze += "########\n";
      soln = "";
      soln += "#o######\n";
      soln += "#o #   #\n";
      soln += "#o## ###\n";
      soln += "#ooooo #\n";
      soln += "# # #o##\n";
      soln += "# ###oo#\n";
      soln += "#  ###oo\n";
      soln += "########\n";
      test(solve(maze) == soln);
  
      maze = "";
      maze += "########\n";
      maze += "#      #\n";
      maze += "#      #\n";
      maze += "#      #\n";
      maze += "## ## ##\n";
      maze += "## ##  #\n";
      maze += "## ### #\n";
      soln = "";
      soln += "########\n";
      soln += "#      #\n";
      soln += "#      #\n";
      soln += "# oooo #\n";
      soln += "##o##o##\n";
      soln += "##o##oo#\n";
      soln += "##o###o#\n";
      test(solve(maze) == soln);
  
      maze = "";
      maze += "#########################################################\n";
      maze += "#     #        #  #  #     #  #  #        #     #       #\n";
      maze += "  ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##  \n";
      maze += "#  #     #  #           #           #  #     #     #  # #\n";
      maze += "#########################################################\n";
      soln = "";
      soln += "#########################################################\n";
      soln += "#oooo #ooooooo #  #  #oooo #  #  #ooooooo #oooo #ooooooo#\n";
      soln += "oo##o##o## ##o## ## ##o##o## ## ##o## ##o##o##o##o## ##oo\n";
      soln += "#  #oooo #  #oooooooooo #oooooooooo #  #oooo #oooo #  # #\n";
      soln += "#########################################################\n";
      test(solve(maze) == soln);
  
      maze = "";
      maze += "# ######################################\n";
      maze += "#   ###     ##                      ## #\n";
      maze += "### ### ### #  ###### ######## #  # #  #\n";
      maze += "# #     # # ##      #        # #### # ##\n";
      maze += "# ####### # ##### # # ###### # #       #\n";
      maze += "#         #     # # #      # # #  ##   #\n";
      maze += "# ### ### ##### # # ######## # #####   #\n";
      maze += "# ### #     #   ###          # ##    ###\n";
      maze += "#     # ### # ######## #######  # #### #\n";
      maze += "# # # # ### #          ##    ## # ## # #\n";
      maze += "# # # #     ########## #   #### # ## # #\n";
      maze += "# # ##### #          # ### #    #      #\n";
      maze += "# #    ## #######  # # #      # ### ####\n";
      maze += "# #### ##   # # #### # #####  #   # #  #\n";
      maze += "# ## ## ###       ## #       ## # # # ##\n";
      maze += "## # #  ###### ## ## ####### ## # # # ##\n";
      maze += "#  # #       # ##                      #\n";
      maze += "###################################### #\n";
      soln = "";
      soln += "#o######################################\n";
      soln += "#ooo###ooooo##                      ## #\n";
      soln += "###o###o###o#  ###### ######## #  # #  #\n";
      soln += "# #ooooo# #o##      #        # #### # ##\n";
      soln += "# ####### #o##### # # ###### # #       #\n";
      soln += "#         #ooooo# # #      # # #  ##   #\n";
      soln += "# ### ### #####o# # ######## # #####   #\n";
      soln += "# ### #     #ooo###          # ##    ###\n";
      soln += "#     # ### #o######## #######  # #### #\n";
      soln += "# # # # ### #oooooooooo##    ## # ## # #\n";
      soln += "# # # #     ##########o#   #### # ## # #\n";
      soln += "# # ##### #          #o### #    #      #\n";
      soln += "# #    ## #######  # #o#      # ### ####\n";
      soln += "# #### ##   # # #### #o#####  #   # #  #\n";
      soln += "# ## ## ###       ## #ooooooo## # # # ##\n";
      soln += "## # #  ###### ## ## #######o## # # # ##\n";
      soln += "#  # #       # ##           ooooooooooo#\n";
      soln += "######################################o#\n";
      test(solve(maze) == soln);
  
      maze = "";
      maze += "#########################################################\n";
      maze += "     #        #     #     #              #     #         \n";
      maze += "#  #   #    #   # #   # #   #          #   # #   #      #\n";
      maze += "#########################################################\n";
      soln = "";
      soln += "#########################################################\n";
      soln += "ooooo#oooooooo#ooooo#ooooo#oooooooooooooo#ooooo#ooooooooo\n";
      soln += "#  #ooo#    #ooo# #ooo# #ooo#          #ooo# #ooo#      #\n";
      soln += "#########################################################\n";
      test(solve(maze) == soln);
  
      for (int t = 0; t &lt; 100; ++t)
      {
          // Randomized test to prevent hardcoding
          maze = "";
          maze += "##################################################\n";
          maze += "                                                  \n";
          maze += "#                                                #\n";
          maze += "##################################################\n";
          for (int i = 0; i &lt; 4; ++i)
          {
              int offset = rand() % 5;
              maze[58 + 10 * i + offset] = '#';
              maze[108 + 10 * i + 3 + offset] = '#';
              maze[108 + 10 * i - 1 + offset] = '#';
              soln = maze;
              int j = 51;
              while (j &lt; 101)
              {
                  if (soln[j] == '#')
                  {
                      soln[j - 1 + 51] = 'o';
                      soln[j - 1 + 52] = 'o';
                      soln[j - 1 + 53] = 'o';
                  }
                  else
                      soln[j] = 'o';
                  ++j;
              }
          }
          test(solve(maze) == soln);
      }
  
      cout &lt;&lt; "Assignment complete." &lt;&lt; endl;
  }
  ``````````````````````
  Vertex.h
  ````````````````````
  #include &lt;vector&gt;
  
  using namespace std;
  
  // A helper class implementing a vertex in 
  // an adjacency-list-based graph.
  class Vertex
  {
  public:
      Vertex(int r, int c)
      {
          row = r;
          col = c;
      }
  
      // Corresponding row and column location in maze
      int row;
      int col;
  
      // List of neighboring vertices
      vector&lt;Vertex*&gt; neighs;
  
  };
  ```````````````````
  Solve.h
  ```````````````````
  #ifndef SOLVE_H
  #define SOLVE_H
  
  #include &lt;vector&gt;
  #include &lt;string&gt;
  #include &lt;unordered_set&gt;
  #include &lt;queue&gt;
  #include &lt;unordered_map&gt;
  
  using namespace std;
  
  string solve(string maze);
  
  #endif 
  
  
  It should print assignment complete to show it runs through all tests.
  </code></pre>