Labyrinth Solver

What about a labyrinth solver function in 16 lines of Python? :-)

3 Responses to “Labyrinth Solver”


  1. 1 Eduardo Habkost

    When I first read the text, I thought “What? A solution to Labyrinthitis?”

  2. 2 Gustavo Niemeyer

    A cure to labyrinthitis in 16 lines of Python would be *really* nice. Hehehe :-)

  3. 3 Dinu

    Even shorter, but also more cryptic ;-)

    from operator import or_
        if reduce(or_, [solve(maze, posx+i, posy+j, sizex, sizey)
                        for i,j in zip((1,-1,0,0), (0,0,1,-1))]):
    

    instead of:

        if (solve(maze, posx+1, posy, sizex, sizey) or
            solve(maze, posx-1, posy, sizex, sizey) or
            solve(maze, posx, posy+1, sizex, sizey) or
            solve(maze, posx, posy-1, sizex, sizey)):
    

Leave a Reply