13. CODE: Store a Grid in Your Program

Store a Grid in Your Program

In order to write the A* search algorithm, you will need a grid or "board" to search through. We'll be working with this board throughout the remaining exercises, and we'll start by storing a hard-coded board in the main function. In later exercises, you will write code to read the board from a file.

To Complete This Exercise:

  1. In the main function, declare a variable board as a vector of vectors of ints: vector<vector<int>> .
  2. Assign this data to the board variable:
{{0, 1, 0, 0, 0, 0},
 {0, 1, 0, 0, 0, 0},
 {0, 1, 0, 0, 0, 0},
 {0, 1, 0, 0, 0, 0},
 {0, 0, 0, 0, 1, 0}}

Note: you will need to include the vector library, just as iostream is included. You will also need to use the namespace std::vector if you want to write vector rather than std::vector in your code.

This exercise will be ungraded, but if you get stuck, you can find the solution in solution.cpp . Finally, if you feel a little crowded in the editor below and need more space to work, you can click the "Expand" button in the lower left corner.


This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity , so you may be able to download them there.

Workspace Information:

  • Default file path:
  • Workspace type: generic
  • Opened files (when workspace is loaded): n/a
  • userCode:

    export CXX=g++-7
    export CXXFLAGS=-std=c++17
    g++() {
    /usr/bin/g++-7 -std=c++17 "$1"
    export -f g++