fork download
  1. import sys
  2. sys.setrecursionlimit(9999999)
  3. #Entrada de datos
  4. entradas = 9
  5. s=[]
  6. while entradas > 0:
  7. entradas = entradas-1
  8. s.append(input().strip().split(" "))
  9. #Función del proceso principal
  10. def principal(s):
  11. if recorrido(s,"V")=="N":
  12. P1 = recorrido(s,"P1")
  13. if P1=="S":
  14. #return principal(s);
  15. return "Continúa validando"
  16. elif P1=="N":
  17. #fumada
  18. return imprimirSolucion(s)
  19. elif P1 =="E":
  20. return imprimirError(s)
  21. else:
  22. return imprimirSolucion(s)
  23.  
  24. def recorrido(s,a):
  25. R="S"
  26. y=0
  27. while y<9:
  28. x=0
  29. while x<9:
  30. #Se clasifican las diferentes acciones
  31. if a=="I":
  32. incluyeIndicadores(y,x)
  33. elif a=="V":
  34. t=verificaSiCompletado(y,x)
  35. if t=="N":
  36. return "N"
  37. x=x+1
  38. y=y+1
  39. return R
  40. def incluyeIndicadores(y,x):
  41. global s
  42. if s[y][x]=="0":
  43. s[y][x]="E-0"
  44. else:
  45. s[y][x]="D-"+s[y][x]
  46. def verificaSiCompletado(y,x):
  47. global s
  48. if s[y][x]=="E-0":
  49. return "N"
  50.  
  51.  
  52.  
  53.  
  54. def imprimirSolucion(s):
  55. return "Resultado correcto"
  56. def imprimirError(s):
  57. return "Resultado erróneo"
  58. recorrido(s,"I")
  59. print(principal(s))
  60. print(s[2][2])
  61.  
Success #stdin #stdout 0.04s 9432KB
stdin
1 2 2 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
2 2 3 4 5 6 7 8 9
2 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
stdout
Resultado correcto
D-3