Advertisement
Matblinx

a

Jun 2nd, 2021
703
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.30 KB | None | 0 0
  1. def imprime_tablero(tablero):
  2.     for l in tablero:
  3.         print("|" , " ".join(l), "|")
  4.     print("")
  5. def revisa_ganador(sim, mat):
  6.     objetivo = len(mat)
  7.     #filas
  8.     for l in mat: #cada linea
  9.         if l.count(sim)== objetivo:
  10.             return True
  11.     #diagonales
  12.     comp = []
  13.     comp_i = []
  14.     for i in range(objetivo):
  15.          comp.append(mat[i][i])
  16.          comp_i.append(mat[i][-(i+1)])
  17.     if comp.count(sim)== objetivo or comp_i.count(sim)==objetivo:
  18.         return True
  19.  
  20.     #columnas
  21.     for j in range(objetivo):
  22.         columna = []
  23.         for l in mat:
  24.             columna.append(l[j])
  25.         if columna.count(sim) == objetivo:
  26.             return True
  27.  
  28.     return False
  29. posicion = int(input())
  30. auxiliar = posicion
  31. tj1 = posicion//10
  32. tj2 = auxiliar%10
  33. if tj1 != 0 and tj2 !=0:
  34.     tj1 -= 1
  35.     tj2 -= 1
  36. tablero_jugadores = [["-","-","-"], ["-","-","-"],["-","-","-"]]
  37. tablero_jugadores[tj1][tj2] = "x"
  38. tablero = imprime_tablero(tablero_jugadores)
  39. print(tablero)
  40. posicion = int(input())
  41. auxiliar = posicion
  42. tj1 = posicion//10
  43. tj2 = auxiliar%10
  44. if tj1 != 0 and tj2 !=0:
  45.     tj1 -= 1
  46.     tj2 -= 1
  47. tablero_jugadores[tj1][tj2] = "O"
  48. tablero += imprime_tablero(tablero_jugadores)
  49. print(tablero)
  50. #victorio = revisa_ganador(imprime_tablero, tablero_jugadores)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement