← View in Interactive Graph

code

import matplotlib.pyplot as plt

plt.figure(figsize=(5,5))

plt.xticks([]), plt.yticks([])

fig, ax = plt.subplots()

fig.patch.set_facecolor('black')

ax.set_facecolor('black')

def line(x1, y1, x2, y2):

"""Draws a line between two points."""

plt.plot([x1, x2], [y1, y2], color='white', linewidth=2)




# Draw outer boundaries

line(0, 0, 10, 0) # Bottom wall

line(0, 0, 10, 0) # Bottom wall

line(10, 0, 10, 10) # Right wall

line(10, 10, 0, 10) # Top wall

line(0, 10, 0, 0) # Left wall



# Draw inner maze walls

line(2, 0, 2, 8)

line(2, 8, 8, 8)

line(8, 8, 8, 2)

line(8, 2, 4, 2)

line(4, 2, 4, 6)

line(4, 6, 6, 6)

line(6, 6, 6, 4)





# Start and end points (optional visualization)

plt.scatter(0.88, 0.44, color='green', label='Start') # Start

plt.scatter(5, 5, color='red', label='End') # End




# Show the legend

plt.legend()



plt.show()





###

Algorithm

^ef43f1

Step-by-Step Algorithm


Tags: #cs #dsa

Miscellaneous