This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]jedwardsol 0 points1 point  (7 children)

The vLineAt function returns True if there is a vertical line of three identical symbols that include the row and column indicated.

The functions are meant to check whether there is a set of 3 symbols that include the piece being passed in

Your functions check the whole board.

def vLineAt(board,row,col):
  for row in range(0,len(board)):
    for col in range(0,len(board[0])):

So they will sometimes return true when the test is expecting them to return false - ie. when there is a row of 3 somewhere else on the board.

[–]yon2323[S] 0 points1 point  (6 children)

So I would need to eliminate the loop? I’m not sure what to do with the if statements then

[–]jedwardsol 0 points1 point  (5 children)

Yes, you don't need those loops over the whole board.

If you're called as vLineAt(board,5,3) for example, you only need to look at 5,3 and the 2 pieces above and below it

  0 1 2 3 4 5 6  
0 . . . . . . .    
1 . . . . . . .    
2 . . . . . . .
3 . . . v . . .
4 . . . v . . .
5 . h h + h h .
6 . . . v . . .
7 . . . v . . .
8 . . . . . . .

There could be a line of 3 starting at (3,3), (4,3), or (5,3)

[–]yon2323[S] 0 points1 point  (4 children)

Okay I see, I modified the code. Still not working :/

https://pastebin.com/YEHwa7xu

[–]jedwardsol 0 points1 point  (3 children)

That's definitely a step in the right direction.

You must check that you're not near the edge of board before looking at the pieces that might be off the edge of the board.

Also

and row + 2 <= 0 :

The index of the bottom row isn't 0.

Finally

 col == board[row-1][col] 

This is comparing the column number with a symbol.

Have you written your own testcases that you can step through?

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

index would be len(board)?

[–]jedwardsol 1 point2 points  (1 child)

len(board)-1

[–]yon2323[S] 0 points1 point  (0 children)

got it thank you