Solving sudoku is not difficult, but it would be nice if you could demonstrate the steps dynamically. Reference: the hardest sudoku solution, python https://www.jianshu.com/p/1b2ee6539d4b quickly

function

  • Read a sudoku title on an open website
  • Or manually enter a sudoku question
  • Submit to background, second solution
  • You can demonstrate the steps in a single step

The demo website: https://mysudo.herokuapp.com/

Above is the GIF, 2.52MB, which is large and can be downloaded to view.

Technology stack

  • Front end: vue.js, pixi.js drawing, Vuetify UI framework website needs to draw sudoku topics, pixi.js is more convenient. In fact, Canvas Canvas is also enough, mainly by learning the next HTML game drawing. UI framework, you can choose anything you want. Vuetify is the perfect companion for desktop + mobile. For pure mobile, Framework7 is available.

  • Back end: Flask server framework, Python crawler Flask is suitable for rapid prototyping. Django is suited for group warfare. In addition, you need to grab topics from public websites, which Python crawlers can do. Problem solving: the previous article, https://www.jianshu.com/p/1b2ee6539d4b has been prepared.

The data flow

Vue uses Ajax to transfer data between the front and back ends.

implementation

Code: https://github.com/kevinqqnj/sudo-dynamic-solve

Vue/Flask is the basic application of Vue/Flask.

Next writing plan:

There are lots of demonstrations online: a phone scans a sudoku problem and the answer is instantly displayed through AUGMENTED reality. The principle is clear. I plan to write the following articles:

  1. Opencv image recognition has python library, also has JS library, front-end, back-end can be achieved. Gaussian blur -> adaptive binarization -> Hochhoff line -> Find the maximum contour -> graph

  2. CNN convolutional network automatically recognizes Keras+Tensorflow, and does not need to recognize handwritten number MNIST. It is enough to find printed number (1-9) database for training. I find chars74k data of http://www.ee.surrey.ac.uk/CVSSP/demos/chars74k/, a total of about 10000 samples, the training also soon, a dozen cycle will reach 99.6% accuracy

Model:

model = Sequential()
model.add(Conv2D(32, kernel_size=(3, 3),
                 activation='relu',
                 input_shape=input_shape))
model.add(Conv2D(64, (3, 3), activation='relu')) model. Add (MaxPooling2D(pool_size=(2, 2)) model. Add (Dropout(0.25)) model. Add (Flatten()) model. activation='relu')) model. The add (Dropout (0.5)) model. The add (Dense (num_classes, activation ='softmax'))

model.compile(loss=keras.losses.categorical_crossentropy,
              optimizer=keras.optimizers.Adadelta(),
              metrics=['accuracy'])
Copy the code

Training:

Train on 8229 samples, Validate on 915 samples of Epoch 1/30 8229/8229 [= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =] 12 ms - 101 - s/step - loss: 0.8978 acc: 0.6994 - val_loss: 0.1746 - val_ACC: 0.9486 Epoch 2/30 8229/8229 [= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =] 12 ms - 95 - s/step - loss: 0.1848 acc: 0.9436 - val_loss: 0.1057 - val_ACC: 0.9628... Epoch 12/30 8229/8229 [= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =] 8 ms - 64 - s/step - loss: 0.0153 acc: 0.9950 - val_loss: 0.0140 - val_acc: 0.9956 Epoch 13/30 8229/8229 [= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =] 8 ms - 67 - s/step - loss: 0.0160 acc: 0.9950-VAL_loss: 0.0125-val_ACC: 0.9967Copy the code
  1. Identify the number, transfer to the back end, calculate the answer, and then use OpencV to draw the mobile phone image

  2. Integrated into the micro channel small program mpvue small program framework, you can use vue.js to quickly write small programs.

Stay tuned for…