Question: def row _ rotation ( exam _ week, current _ seat _ status ) : total _ rows = 6 total _ columns = 5
def rowrotationexamweek, currentseatstatus:
totalrows
totalcolumns
# Find the current row of AA
positionaa
for i in rangetotalrows:
for j in rangetotalcolumns:
if currentseatstatusijAA:
positionaa i
break
if positionaa :
break
# Calculate new position after rotation indexed
newrow positionaa examweek totalrows
# Initialize a new seat status for the coming week
newseatstatus
for i in rangetotalrows:
row
for j in rangetotalcolumns:
row.append
newseatstatus.appendrow
# Shift rows according to the exam week
for i in rangetotalrows:
newrowindex i examweek totalrows
for j in rangetotalcolumns:
newseatstatusnewrowindexj currentseatstatusij
# Print the new seating arrangement
for i in rangetotalrows:
for j in rangetotalcolumns:
printnewseatstatusij end
print # New line after each row
# Return the new row for AAindexed for the output
return newrow
# Example usage:
examweek
currentseatstatus
ABCDE
FGHIJ
KLMNO
PQRST
UVWXY
ZAABBCCDD
newrowforaa rowrotationexamweek, currentseatstatus
printfYour friend AA will be on row newrowforaa
make this code more simple
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
