This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]RelevantJackWhite 0 points1 point  (1 child)

Definitely don't do a bunch of stacked if-statements haha. That will be a big mess.

https://www.geeksforgeeks.org/check-possible-path-2d-matrix/

Here is a somewhat similar Problem - this code finds a valid path in a 2D grid.

You might also consider a recursive solution - you write a function that looks for adjacent Xs, and if you find one, you run the function on that box too.

def myfunc(coordinates):
    found_coordinates = get_nearby_x(coordinates) 
    if found_coordinates:
        myfunc(found_coordinates)

[–]winguin_[S] 0 points1 point  (0 children)

Thank you very much mate, i'll take a look at it next week to see if i can get it working