## Adobe Interview Question for Computer Scientists

Country: United States

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````def safe_locations(board=(7,7), queen=(0,0)):
def is_diagonal(point):
x1 = queen
if x1[0]+1 <= board[0] and x1[1]+1 <= board[1]:
x2 = (x1[0]+1, x1[1]+1)
else:
x2 = (x1[0]-1, x1[1]-1) if x1[0]-1 >= 0 and x1[1]-1 >= 0 else None

if x1[0]+1 <= board[0] and x1[1]-1 >= 0:
x3 = (x1[0]+1, x1[1]-1)
else:
x3 = (x[0]-1, x1[1]+1) if x1[0]-1 >= 0 and x1[1]+1 < board[1] else None

d1 = abs((x2[1] - x1[1]) / (x2[0] - x1[0])) if x2 is not None else None
d2 = abs((x3[1] - x1[1]) / (x3[0] - x1[0])) if x3 is not None else None

d = abs((point[1] - x1[1]) / (point[0] - x1[0]))
return d == d1 or d == d2

results = []

for i in range(board[0]+1):
if i == queen[0]:
continue

for j in range(board[1]+1):
if j == queen[1]:
continue

if is_diagonal((i, j)):
continue

results.append((i,j))

return results``````

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.