Ministério da Educação
Brasil um país de todos
Personal tools
Navigation
Log in


Forgot your password?
 
Document Actions

engine.py

by Cicero Garrozi last modified 2015-06-26 04:58

Click here to get the file

Size 1 kB - File type text/python-source

File contents

def verificaGanhador(m):
    ganhou = ""

    #verificando horizontais:
    if m[0][0] != "_" and m[0][0] == m[0][1] and m[0][1] == m[0][2]:
        ganhou = m[0][0]
    elif m[1][0] != "_" and m[1][0] == m[1][1] and m[1][1] == m[1][2]:
        ganhou = m[1][0]
    elif m[2][0] != "_" and m[2][0] == m[2][1] and m[2][1] == m[2][2]:
        ganhou = m[2][0]
    #verificando verticais:
    elif m[0][0] != "_" and m[0][0] == m[1][0] and m[1][0] == m[2][0]:
        ganhou = m[0][0]
    elif m[0][1] != "_" and m[0][1] == m[1][1] and m[1][1] == m[2][1]:
        ganhou = m[0][1]
    elif m[0][2] != "_" and m[0][2] == m[1][2] and m[1][2] == m[2][2]:
        ganhou = m[0][2]
    #verificando diagonal principal:
    elif m[0][0] != "_" and m[0][0] == m[1][1] and m[1][1] == m[2][2]:
        ganhou = m[0][0]
    #verificando diagonal secundaria:
    elif m[2][0] != "_" and m[2][0] == m[1][1] and m[1][1] == m[0][2]:
        ganhou = m[2][0]

    return ganhou
        
        

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: