Question: #please translate this code from python to ruby and make sure it compiles a board #took out the colons from the for loops and the

#please translate this code from python to ruby and make sure it compiles a board

#took out the colons from the for loops and the if/else statements

#had to manually do the tabbing so spacing might be off

board = [ [0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0],

[0, 0, 0, 0, 0, 0, 0, 0] ]

def queenSafe(column, row)

for i in range(column, -1, -1)

if board[row][i]

return False

for j, i, in zip(range(row - 1, -1, -1), range(column - 1, -1, -1))

if board[j][i]

return False

for j, i in zip(range(row + 1, 8), range(column - 1, -1, -1))

if board[j][i]

return False

return True

def solution(column)

if column >= 8

for j in board

print(j)

return True

for j in range(8)

if(queenSafe(column, j))

board[j][column] = 1

if solution(column + 1)

return True

else

board[j][column] = 0

return False

# print first found solution

solution(0)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!