top of page

Automatic Sudoku Solver

 

Sudoku Solver Script based on towardsdatascience which uses the following modules PyAutoGUI, time and copy.

​

Purpose: Expand Python Knowledge and to improve the script with additional functionalities


Improvements

  1. Select the correct window

  2. Add a emergency stop button.

  3. Decrease delay between actions done by PyAutoGUI

 

Select Correct Window
As the original code only works if the window is on the foreground the following allows it to select that window.
The line was added to ensure that the site is up and the script will run only if it the site is found.

 

windowselect pyautogui.getWindowsWithTitle("Sudoku")[1]
windowselect.activate() 

 

Emergency Quit Button
As there was no way to stop the script once it was ran.
This line was added to exit the script once the "esc" key is pressed. 


Note: If letter/number is used and pressed between the time the script is typing number the quit key might not be registered.

import keyboard
if keyboard.is_pressed('esc'):
    quit()

Decrease Delay Between Actions
This line was added to the function that fills the cell of the sudoku on the site websudoku which decreased the delay between actions from 0.1 seconds per click (default) to 0.01 a 10x increase.

pyautogui.PAUSE 0.01

Results

Original.gif
Original Code
Improved.gif
Added Less Delay
esc.gif
Press ESC Key
bottom of page