# We will need the board to hold the info import threeInARowBoard ### Your code will be after this point ### ## The three in a row solver will read a file, such as 2018-03-30-midium-6x6.in ## which has the following format ## 6 ## --W-B- ## ------ ## BB--W- ## -B---- ## -----W ## -BW--- ## The first line indicates the number of rows and columns, n. ## The rest of the file will contain n lines of n characters each. ## The characters will be B, indicating it must be blue, ## W, indicating it must be white, or -, indicating it may be either. ## Your code will attempt to find a solution with the following rules. ## 1. There cannot be three of the same color consecutively in a row or column ## 2. The number of blues and whites must be equal in any given row and column ## To solve the problem, you will need to find the next '-', in order to ## put one color there, see if that works and if not, try the other one. ## The "see if that works" part is the recursive call. ## Keep in mind that if the first one failed, you need to try the second ## and if both failed set it back to '-' and return failure. ## Setting it back and returning failure will allow the entire attempt to do the ## backtracking. ## In order to do this, I think is easiest to conceptualize by restating ## the problem to include the current location. ## This will be easiest to do if you use many helper functions. ## Most things you will do can be broken down into simple tasks. def findSolution(board) -> bool: # I said you need to find the next dash, how are you going to do that? # Is there already a way to do that? # You found a dash, what are you going to do now? # How are you going to test things? # What if that did not work? # There are many helper functions that you will be writing for this. # There are two basic ways to approach that # 1. Write the function above and make notes of what helper functions you need # 2. Think of what helper functions you need and write those first # 3. If you choose option 2, you will probably miss something, which is okay, just write them as needed. # Obviously, you will replace this line with more code return True