Python 3 BFS solution


#1
def getCoordinate(value):
    row = (value-1)//10 
    col = (value-1)%10
    return row,col


class Solution:
    def snakeLadder(self, A, B):
        board = [[-1]*10 for _ in range(10)]
    
        for i in range(len(A)):
            k,j = getCoordinate(A[i][0])
            board[k][j] = A[i][1]
        
        for i in range(len(B)):
            k,j = getCoordinate(B[i][0])
            board[k][j] = B[i][1]
        
        visited = [[0]*10 for _ in range(10)]
        queue = []
        queue.append(1)
        visited[0][0] = 1
    
        die_roles = 0
    
        while queue:
            size = len(queue)
            for one in range(size):
                curr_node = queue[0]
                queue.pop(0)
                for k in range(1,7):
                    row,col = getCoordinate(curr_node+k)
                    if visited[row][col] == 0:
                        visited[row][col] = 1
                        if curr_node+k == 100 or board[row][col]==100:
                             return die_roles+1
                        if board[row][col] == -1:
                            queue.append(curr_node+k)
                        else:
                            queue.append(board[row][col])
            die_roles +=1
       
        return -1