Queen's Attack II Discussions | Algorithms | HackerRank
We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
obstacles = {(ob[0],ob[1]) for ob in obst}
mvs, count = [(1,0),(0,1),(-1,0),(0,-1),(1,1),(-1,-1),(-1,1),(1,-1)], 0
for m in mvs:
cr, cc = r_q, c_q
while (cr + m[0] >= 1 and cr + m[0] <= n) and (cc + m[1] >= 1 and cc + m[1] <= n):
cr += m[0]
cc += m[1]
if (cr, cc) in obstacles:break
count += 1
return count
Queen's Attack II
You are viewing a single comment's thread. Return to all comments →
Python Solution