Can you help me choose the correct data structure? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can you help me choose the correct data structure?

Hello everyone. I am working on a programming exercise. I should output symbol of the player that would win a tic tac toe game (on paper with unlimited space). I get input in this format: X 5 2 O 5 3 X 7 4 O 6 3 ... The numbers are x and y coordinades of the ticked cell. My problem is, I don't know which data structure should I use to save loaded moves. Currently I use custom class for all checked cells. The class stores symbol of the player (O or X), x and y coordiates of the cell and reference to all 8 cells touching it (if checked). I store all the cell objects in a list, but I feel there is a better solution. I need to check if there are 5 symbols of the same player in any direction after each move. The game can have up to 500.000 rounds and the cootrdinates have values 0 to 1.000.000 in both x and y directions.

24th Oct 2018, 8:43 PM
Jan Štěch
Jan Štěch - avatar
1 Answer
+ 1
Maybe matrixes/lists? Just remember that nothing is unlimited, you may add a limit anywhere.
29th Oct 2018, 11:57 PM
Alexander Santos
Alexander Santos - avatar