Good morning,
I decided to take a crack at the edx machine learning course, and I had a question about how to approach writing the code.
They seem to run the programs from a powershell using the command line interface whereas everything I've done so far has been compile and run sort of code.
The code provided in the class is shown below, and I can call it from a powershell by typing in: python maze.py maze.txt
I decided to take a crack at the edx machine learning course, and I had a question about how to approach writing the code.
They seem to run the programs from a powershell using the command line interface whereas everything I've done so far has been compile and run sort of code.
The code provided in the class is shown below, and I can call it from a powershell by typing in: python maze.py maze.txt
if len(sys.argv) != 2:
sys.exit("Usage: python maze - DFS.py maze.txt")
m = Maze(sys.argv[1])
print("Maze:")
m.print()
print("Solving...")
m.solve()
print("States Explored:", m.num_explored)
print("Solution:")
m.print()
m.output_image("maze.png", show_explored=True)Is the code above a better way to approach these types of problems, or should I aim to import the files and compile them together? I mean, I can compile and run it if I do something like this:#I added this part to make it work
sys.argv = ["maze - DFS.py", "maze.txt"]
#I added this part to make it work
if len(sys.argv) != 2:
sys.exit("Usage: python maze - DFS.py maze.txt")
m = Maze(sys.argv[1])
print("Maze:")
m.print()
print("Solving...")
m.solve()
print("States Explored:", m.num_explored)
print("Solution:")
m.print()
m.output_image("maze.png", show_explored=True)
