My algorithm homework revolves around matching 4 "O"
's or 4 "X"
's on a diagonal, horizontal, or vertical. Hopefully that makes sense...
This is what the data looks like below (2D tuples) where I need to recreate a function that returns "O"
or "X"
or False
depending on what is found.
xwins = ((None, None, None, None, None, None, None),
(None, None, None, None, None, None, None),
(None, None, None, None, "X" , None, None),
(None, None, None, "X" , "O" , "O", None),
(None, "O" , "X" , "X" , "O" , "X", None),
("O" , "X" , "O" , "O" , "O" , "X" , "X"))
owins = ((None, None, None, None, None, None, None),
(None, None, None, None, None, None, None),
("O" , "O" , "O" , "O" , None, None, None),
("O" , "X" , "X" , "X" , None, None, None),
("X" , "X" , "X" , "O" , "X" , None, None),
("X" , "O" , "O" , "X" , "O" , None, None))
nowins =(("X" , "X" , None, None, None, None, None),
("O" , "O" , None, None, None, None, None),
("O" , "X" , "O" , "O" , None, "O" , "O" ),
("O" , "X" , "X" , "X" , None, "X" , "X" ),
("X" , "X" , "X" , "O" , "X" , "X" , "O" ),
("X" , "O" , "O" , "X" , "O" , "X" , "O" ))
Can someone give me a tip on if I should change the data structure? Originally I went at this creating a numpy array out of the data but am having a hard time dealing with the None
items in numpy as well as trying to convert the X
and O
strings to an int...and now I don't know what to do...need to start over from scratch.
Would anyone have any tips or pseudo-code I can glance at, not solve this but some tips would be useful what data structure to use and methods to the madness, ha. What sort of search algorithm would the solution be considered? Not a lot of wisdom here...
xwins owins nowins
is how the data is presented in the problem.....Should I flatten the nested tuples into one large tuple? $\endgroup$