Question: 2 Write a function: def solution ( B ) which, given a square board of N N size describing Aladdin's and Jafar's pawns, retums the

2
Write a function:
def solution(B)
which, given a square board of NN size describing Aladdin's and Jafar's pawns, retums the maximum number of pawns Jafar can beat in one turn. If none of Aladdin's pawns can be beaten, the function should retum .
Jafar's pawn is described by the '0' character, Aladdin's pawns by x' characters and empty fields by : '(dots). The board is described from top to bottom and from left to right.
For example, given:
B[]=-dotsdots
B[1]=dots..
B[2]=....X.
B[3]=.X dots
B[4]=dots.x.
B[5]=dots0..
the function should retum 2(Jafar can beat Aladdin's pawn in the upright direction and then another one in the up-left direction).
Given:
B[]=?**dots.
B[1]=?**dots.
B[2]=?**..0dots
B[3]=?**dots..
B[4]=?4dots.
the fiuntion ohneAd rotiun a
Assume that:
. N is an imeger writin the range [1.30]
all swings in B are made only of the following characters - :'? and/co "0%:
the bourd is NN square:
the bourd contzins eractly one pawn cowned by Jafar.

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!