AN session statusboard question.-Answser?

107 views
Skip to first unread message

Kamala Malar

unread,
Oct 30, 2023, 11:55:49 AM10/30/23
to Discussion forum for The Joy Of Computing Using Python
Did anyone got question like these question? you have to type answer . Did anyone remember question completly and answer?
def statusboard(M):
    for i in range(len(M)):
        for j in range(1,4):
            if M[i][j-1]!=M[i][j]:
                index=-1
                break
            if M[j-1][i]!=M[j][i]:
                index=-1
                break
        if index>0:
            return i
    return i
b=[['x','o','x','o'],
   ['x','x','o','x'],
   ['o','o','x','x'],
   ['0','o','x','x']]

print(statusboard(b))

Ajinkya Kerkar

unread,
Oct 30, 2023, 1:04:24 PM10/30/23
to Discussion forum for The Joy Of Computing Using Python, Kamala Malar
Yep I got that question too! It was the last question for me.   Session III   Q 24.

The value I got was 2.

BTW, I believe it was something like these>>>

def statusboard(M):
    n = len(M)

    for i in range(n):
        index = i
        for j in range(1,n):
            if M[i][j]!=M[i][j-1]:

                index=-1
                break
            if M[j-1][i]!=M[j][i]:
                index=-1
                break
        if index>0:
            return i
    return i
board =[['x','o','x','o'],

   ['x','x','o','x'],
   ['o','o','x','x'],
   ['o','o','x','x']]
print(statusboard(board))

& I just can't recall the values in board anymore.. 


Reply all
Reply to author
Forward
0 new messages