Simple and unique Python code that generates a random maze using the depth-first search algorithm
import random
def create_maze(width, height): maze = [['#' for _ in range(width)] for _ in range(height)] stack = [(0, 0)]
while stack:
x, y = stack[-1]
neighbors = []
if x > 1:
neighbors.append((x - 2, y))
if x < width - 2:
neighbors.append((x + 2, y))
if y > 1:
neighbors.append((x, y - 2))
if y < height - 2:
neighbors.append((x, y + 2))
unvisited_neighbors = [(nx, ny) for nx, ny in neighbors if maze[ny][nx] == '#']
if unvisited_neighbors: [steel saria price in pakistan](https://pakprices.pk/steel-rate-today/)
nx, ny = random.choice(unvisited_neighbors)
maze[ny][nx] = ' '
maze[y + (ny - y) // 2][x + (nx - x) // 2] = ' '
stack.append((nx, ny))
else:
stack.pop()
maze[0][0] = 'S'
maze[height - 1][