Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

seatCol = {0: A, 1: B, 3: C, 4: D} seatRow = {0: 1, 2: 1, 3: 2, 4:3, 5: 4, 6: 5,

ID: 3736314 • Letter: S

Question

seatCol = {0: A, 1: B, 3: C, 4: D}

seatRow = {0: 1, 2: 1, 3: 2, 4:3, 5: 4, 6: 5, 7: 6, 8: 7, 9: 8, 10: 9, 11: 10, 12: 11, 13: 12, 14: 13, 15: 14, 16: 15, 17: 16, 18: 17, 19: 18, 20: 19}

count = 0

def indicesToSeat(seatRow, seatCol):

if seatCol == 0:

col = 'A'

  

elif seatCol == 1:

col = 'B'

  

elif seatCol == 2:

col = 'C'

  

elif seatCol == 3:

col = 'D'

  

else:

print("Enter a number between 0 and 3.")

  

if (0 <= seatRow <= 19):

row = seatRow +1

  

else:

print("Enter a number between 0 and 19.")

  

return (col, row)

def isSeatReserved(seats, seatRow, seatCol):

if seats == None:

return True

else:

return False

# confused

def findIslePairsAvailable(seats):

seats = (seatRow, seatCol)

while ((seatCol == 1 and 2) or (3 and 4)) and (5 <= seatRow <=15):

if isSeatAvailable == True:

count +=1

else:

return count

#Confused of airplane

def fragmentationCount(seats):

seats = (seatRow, SeatCol)

if (seatCol == 1 or 3) and (5 <= seatRow <=19):

How do i do this function? Any tips? The last two function Im really confused on how can i do it. Any tips or explanation to this question is helpful?

ints) The next image is the seating of a Bombardier CRJ900 of 2345789 10 11 Connection Fleet seats in rows A and D are called window eats Unlike in the image above, assume that airplane does contain seats B1 B4 (in First s urvaloy class). 2 791011 12 13 14 15 16 12 18 19 20 You are hired to help create functions for the reservation and ticketing system for flights on this airplane Assume the seats are represented using a two-dimensional list, called seats. Assume the first 4 rows are "First class," and the rest form the "Delta Comfort" class. Assume that, if a seat is available, it would have the value of None in it. If a seat is ta contain the corresponding ticket number (a string value). ken, its corresponding cell in the two-dimensional list seats will In what follows: airplane. The parameter seats is the two-dimensional arrays representing the seats on the The parameter seatRow is a value between 0 and 19; and · . The parameter seatCol is one of the values 0 (for 'A). (1, for 'B'), 2 (for 'C") or 3 (for D'). Define the following functions: indicesToSeat (seatRow, seatcol) : returns the corresponding seat number on the lane. For example the statement s -indicesFromSeat (8, 1) shall set s to "89" (5 points) ksSeatReserved (seats, seatRow, seatco1) : returns True if the seat in the given seatRow and seatcol is taken. Otherwise, the function returns False. (5 points) "( findIslePairsAvailable (seats). This funtion returns the first isleseat pair (B s function returns the first isle seat pair (B-C) available in the "Comfort" class. A seat pair in row Xis available if BX and CX.(10 points) fragmentation Count(scats): returns the number of available seats that have a reserved seat next to them. For example, if seat B4 is reserved but A4 is not, then seat B4 would be counted as part of the result. This function shall not consider cross-aisle seats. (Hint: search by columns; check only seat pairs A-B and C-D) (10 points) https://www.expressjet.com/assets/Uploads/SeatMaps/dl-crj900.png Page 2 of 5

Explanation / Answer

# your isSeatReserved logic is wrong , since it is an array we have to access that element identified by the seatRol #and seatCol and check if its none

def isSeatReserved(seats, seatRow, seatCol):

if seats[seatRow][seatCol] == "None":

return True

else:

return False

# the function needs to find the first row number X in the comfort zone such that both seats in the B and C column #are available. 1,2 is B,C column

def findIslePairsAvailable(seats):

while (5 <= seatRow and seatRow<=15):

if ((seats[seatRow][1] == 'None') && (seats[seatRow][2] == 'None')):

return seatRow

else:

seatRow+=1

return 0

# so now we need to check if adjacent , non cross aisle has one seat booked in them

#for rows 1 to 4 check only C,D columns as B row doesn't have seats

#check for the condition (if seat in col 0 is booked and col 1 is not booked) and col 0 is not booked and col 1 is #booked  

def fragmentationCount(seats):

count = 0

while(0 <= seatRow and seatRow<4):

if(( seats[seatRow][2] == 'None' and  seats[seatRow][3] != 'None' ) or ( seats[seatRow][2] != 'None' and  seats[seatRow][3] == 'None' )):

count+=1

seatRow+=1

else:

seatRow+=1

while(4 <= seatRow and seatRow<15):

if(( seats[seatRow][2] == 'None' and  seats[seatRow][3] != 'None' ) or ( seats[seatRow][2] != 'None' and  seats[seatRow][3] == 'None' )):

count+=1

if(( seats[seatRow][0] == 'None' and  seats[seatRow][1] != 'None' ) or ( seats[seatRow][0] != 'None' and  seats[seatRow][1] == 'None' )):

count+=1

seatRow+=1

else:

seatRow+=1

return count