Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

It shows I am wrong in one of steps, Need help! 6.20 Breakout Rooms: Rooks on a Chessboard Write a function that, when given a

It shows I am wrong in one of steps, Need help! image text in transcribed
image text in transcribed
6.20 Breakout Rooms: Rooks on a Chessboard Write a function that, when given a list of rooks on a chessboard and a square on the chessboard, returns the number of times the square is attacked by the rooks. The chessboard is an 8 by 8 grid with each square a tuple of a column (a through "h) and a row (1 through 8). A rook moves vertically and horizontally, attacking each square on its column or its row (but not both-it can't defend itself). We assume the rooks can pass through each other a rook on a can attack the square a3 even if there is another rook on a5. The below image highlights all the squares that a particular rook attacks So using the above image as an example value, if rooks is [(e,4)) and square is (e 3), the function should return 1 because the square at location is attacked by the one rook. But if rooks is [(e',4)) and square is (1.8), the function should return O. In other words, numattackingrooks([('e',4)). ('e',3)) = 1 numattackingrooks([ce',4)), (1,8)) = 0 Hint You'll want to keep a counter variable during the loop that keeps track of the number of attacking rooks. For each rook, you want to increment the counter (this means increase it by 1) if that rook attacks the square in question 295818 1710234 main py of rook in the rock list which can attack the we_rowser rook_rowl in rook 1 posite..c'e, boksitle 411 (13 boksi 41.1.1.6.3.C. mode When done developing your program press the Submit for grading bumon below. This will Submit your program for auto thi -10101012121212121212.22/12 59 PM on 02/17/21 Total score: 2/4 Download this submission 11 D/1 0 Hember that not come defenditore D/1 6.20 Breakout Rooms: Rooks on a Chessboard Write a function that, when given a list of rooks on a chessboard and a square on the chessboard, returns the number of times the square is attacked by the rooks. The chessboard is an 8 by 8 grid with each square a tuple of a column (a through "h) and a row (1 through 8). A rook moves vertically and horizontally, attacking each square on its column or its row (but not both-it can't defend itself). We assume the rooks can pass through each other a rook on a can attack the square a3 even if there is another rook on a5. The below image highlights all the squares that a particular rook attacks So using the above image as an example value, if rooks is [(e,4)) and square is (e 3), the function should return 1 because the square at location is attacked by the one rook. But if rooks is [(e',4)) and square is (1.8), the function should return O. In other words, numattackingrooks([('e',4)). ('e',3)) = 1 numattackingrooks([ce',4)), (1,8)) = 0 Hint You'll want to keep a counter variable during the loop that keeps track of the number of attacking rooks. For each rook, you want to increment the counter (this means increase it by 1) if that rook attacks the square in question 295818 1710234 main py of rook in the rock list which can attack the we_rowser rook_rowl in rook 1 posite..c'e, boksitle 411 (13 boksi 41.1.1.6.3.C. mode When done developing your program press the Submit for grading bumon below. This will Submit your program for auto thi -10101012121212121212.22/12 59 PM on 02/17/21 Total score: 2/4 Download this submission 11 D/1 0 Hember that not come defenditore D/1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

More Books

Students also viewed these Databases questions

Question

Question What is a Roth 403 (b) plan?

Answered: 1 week ago

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago