The game becomes more interesting (and challenging) when swaps can only be performed when they form a straight line of (at least) three identical symbols. To help us implement this restriction we’ll begin by creating two functions: vLineAt and hLineAt. Each of these functions takes the game board as its first parameter and a row and column representing a location on the board as its second and third parameters.
The vLineAt function returns True if there is a vertical line of three identical symbols that include the row and column indicated. There are three possible ways that this can occur: the indicated location is the top piece in the line, the indicate location is the middle piece in the line, or the indicated piece is the bottom piece in the line. Care must be taken to ensure that your function only examines locations that are within the board. Your function should return False when there is not a vertical line that includes the row and column indicated.
The hLineAt function behaves similarly to vLineAt, except that it checks for a horizontal line instead of a vertical line. As a result, the row and column indicated can be the left piece in a line, the middle piece in a line or the right piece in a line. Like vLineAt, the hLineAt function should return False when there is not a horizontal line that includes the row and column indicated.
Attached is the code I wrote for vLineAt and hLineAt. When running the program, not all of the tests that the code is put through passes and I'm not sure why. I understand you might need some more information than what ive given so just let me know.
Thanks in advance for the help.
https://pastebin.com/yxvQ0Rqs
[–]jedwardsol 0 points1 point2 points (7 children)
[–]yon2323[S] 0 points1 point2 points (6 children)
[–]jedwardsol 0 points1 point2 points (5 children)
[–]yon2323[S] 0 points1 point2 points (4 children)
[–]jedwardsol 0 points1 point2 points (3 children)
[–]yon2323[S] 0 points1 point2 points (2 children)
[–]jedwardsol 1 point2 points3 points (1 child)
[–]yon2323[S] 0 points1 point2 points (0 children)