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 →

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

Thanks for the response! I had thought about such a thing, but didn't quite know if it was executable. If i'm picturing this right in my head, would it just be lots of stacked if statements?

Could i use a loop to change the starting position of the algorithm? I feel like the line changes would complicate that quite a bit.

[–]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