adding backtracking prediction to the app
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import streamlit as st
|
2 |
-
from sudoku.train import SudokuTrialErrorLightning
|
3 |
from sudoku.helper import display_as_dataframe, get_grid_number_soluce
|
4 |
import numpy as np
|
5 |
import re
|
@@ -116,7 +116,14 @@ if n_sol==1:
|
|
116 |
while new_X.sum()<729:
|
117 |
i+=1
|
118 |
st.markdown(f'iteration {i}')
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
st.html(display_as_dataframe(new_X).to_html(escape=False, index=False))
|
121 |
new_X_sum = new_X.sum()
|
122 |
assert new_X_sum> X_sum
|
|
|
1 |
import streamlit as st
|
2 |
+
from sudoku.train import SudokuTrialErrorLightning, TrialEveryPosException
|
3 |
from sudoku.helper import display_as_dataframe, get_grid_number_soluce
|
4 |
import numpy as np
|
5 |
import re
|
|
|
116 |
while new_X.sum()<729:
|
117 |
i+=1
|
118 |
st.markdown(f'iteration {i}')
|
119 |
+
try:
|
120 |
+
new_X = model.predict(new_X)
|
121 |
+
except TrialEveryPosException:
|
122 |
+
st.markdown('''## The grid is super evil!
|
123 |
+
please share it as A Discussion in the `Community` tab.
|
124 |
+
Except if it is this one: https://www.telegraph.co.uk/news/science/science-news/9359579/Worlds-hardest-sudoku-can-you-crack-it.html''')
|
125 |
+
is_valid, new_X = model.backtracking_predict(new_X)
|
126 |
+
assert is_valid
|
127 |
st.html(display_as_dataframe(new_X).to_html(escape=False, index=False))
|
128 |
new_X_sum = new_X.sum()
|
129 |
assert new_X_sum> X_sum
|