You are viewing a single comment's thread. Return to all comments →
def queensAttack(n, k, r_q, c_q, obstacles): print(obstacles) obstacles = set(tuple(map(tuple, obstacles))) directions = [(1,-1), (1,0), (1,1), (0,-1), (0,1), (-1,-1), (-1,0), (-1,1)] print(dir) ans = 0 for dy, dx in directions: y, x = r_q, c_q while True: y += dy x += dx if not (1 <= y <= n): break if not (1 <= x <= n): break if (y,x) in obstacles: break ans +=1 return ans
Seems like cookies are disabled on this browser, please enable them to open this website
Queen's Attack II
You are viewing a single comment's thread. Return to all comments →