• ICE BASE Can You Pass?

 

code works on pc but does not work in heckio

def can_pass(matrix, first, second, prev=list()):
    prev.append(str(first[0]) + str(first[1]))
    steps = ((1, 0), (-1, 0), (0, 1), (0, -1))
    for s in steps:
        try:
            if str(first[0] + s[0]) + str(first[1] + s[1]) in prev:
                continue
            if matrix[first[0] + s[0]][first[1] + s[1]] == matrix[first[0]][first[1]]:
                if first[0] + s[0] == second[0] and first[1] + s[1] == second[1]:
                    return True
                prev.append(str(first[0] + s[0]) + str(first[1] + s[1]))
                if can_pass(matrix, (first[0] + s[0], first[1] + s[1]), second, prev) is True:
                    return True
                else:
                    prev.remove(str(first[0] + s[0]) + str(first[1] + s[1]))
                    continue
        except IndexError:
            pass
    return False


if __name__ == '__main__':
    assert can_pass(((5,6),(6,6),(6,5),(6,6),(7,6),(6,6),(6,7),(6,6),(8,6),(6,6)), (9,1), (0,1)) == True, 'First example'
.