rubend18 commited on
Commit
4a38405
·
1 Parent(s): 27aecdd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -18
app.py CHANGED
@@ -1,16 +1,19 @@
1
  def print_board(tablero):
 
2
  for i in range(len(tablero)):
3
  if i % 3 == 0 and i != 0:
4
- print("------+-------+------")
5
 
6
  for j in range(len(tablero[0])):
7
  if j % 3 == 0 and j != 0:
8
- print("| ", end="")
9
 
10
  if j == 8:
11
- print(tablero[i][j])
12
  else:
13
- print(str(tablero[i][j]) + " ", end="")
 
 
14
 
15
  def resolver(tablero):
16
  buscar = buscar_vacio(tablero)
@@ -60,18 +63,7 @@ def buscar_vacio(tablero):
60
 
61
  return None
62
 
63
- # Convertir la cadena de entrada en una lista de listas
64
- cadena = "780400120600075009000601078007040260001050930904060005070300012120007400049206007"
65
- tablero = []
66
- for i in range(0, 81, 9):
67
- row = [int(num) for num in cadena[i:i+9]]
68
- tablero.append(row)
69
-
70
- # Resolver el sudoku
71
- resolver(tablero)
72
 
73
- # Imprimir el tablero
74
- print_board(tablero)
75
 
76
 
77
  # ********************************************************************************
@@ -81,12 +73,15 @@ print_board(tablero)
81
  import gradio as gr
82
 
83
  def function(cadena):
 
84
  tablero = []
85
  for i in range(0, 81, 9):
86
- row = [int(x) for x in cadena[i:i+9]]
87
  tablero.append(row)
88
- resolver(tablero)
89
- return resolver(tablero)
 
 
90
 
91
  demo = gr.Interface(
92
  fn=function,
 
1
  def print_board(tablero):
2
+ output = ""
3
  for i in range(len(tablero)):
4
  if i % 3 == 0 and i != 0:
5
+ output += "------+-------+------\n"
6
 
7
  for j in range(len(tablero[0])):
8
  if j % 3 == 0 and j != 0:
9
+ output += "| "
10
 
11
  if j == 8:
12
+ output += str(tablero[i][j]) + "\n"
13
  else:
14
+ output += str(tablero[i][j]) + " "
15
+
16
+ return output
17
 
18
  def resolver(tablero):
19
  buscar = buscar_vacio(tablero)
 
63
 
64
  return None
65
 
 
 
 
 
 
 
 
 
 
66
 
 
 
67
 
68
 
69
  # ********************************************************************************
 
73
  import gradio as gr
74
 
75
  def function(cadena):
76
+
77
  tablero = []
78
  for i in range(0, 81, 9):
79
+ row = [int(num) for num in cadena[i:i+9]]
80
  tablero.append(row)
81
+
82
+ resolver(tablero)
83
+
84
+ return print_board(tablero)
85
 
86
  demo = gr.Interface(
87
  fn=function,