Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def validate_cell(self, sudoku_solved, val, i, j): | |
# getting index for block ( 9 blocks of 3x3 size) | |
block_i = i // 3 | |
block_j = j // 3 | |
# check block | |
for b_i in range(block_i * 3, block_i * 3 + 3): | |
for b_j in range(block_j * 3, block_j * 3 + 3): | |
if sudoku_solved[b_i][b_j] == val: | |
return False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def __solve_backtrack__(self, i, j, visualize=False): | |
# Changing row if col index reaches end of the row | |
if j > 8: | |
j = 0 | |
i += 1 | |
# end condition | |
if i > 8: | |
if visualize == False: | |
eel.draw_sudoku(self.sudoku_solved) | |
return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def __generator__(self, grid, i, j): | |
number = [1, 2, 3, 4, 5, 6, 7, 8, 9] | |
if j > 8: | |
j = 0 | |
i += 1 | |
# end condition | |
if i > 8: | |
return True | |
# skipping cell if the cell has already a number |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def __generator__(self, grid, i, j): | |
number = [1, 2, 3, 4, 5, 6, 7, 8, 9] | |
if j > 8: | |
j = 0 | |
i += 1 | |
# end condition | |
if i > 8: | |
return True | |
# skipping cell if the cell has already a number |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate_sudoku(self, level=2): | |
# generate solved sudoku | |
self.generate_solved_sudoku() | |
if level == 1: | |
remove_cell = random.randint(32, 38) | |
if level == 2: | |
remove_cell = random.randint(40, 46) | |
if level == 3: | |
remove_cell = random.randint(48, 52) | |
if level == 4: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JavaScript functions exposed to python | |
eel.expose(draw_sudoku) | |
eel.expose(update_sudoku) | |
// Function for drawing sudoku | |
function draw_sudoku(data) { | |
for (i = 0; i < 81; i++) { | |
// row and col values for corresponding i values | |
row = ~~(i / 9); | |
col = i % 9; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# python functions exposed to javascript | |
@eel.expose | |
def generate_new_sudoku(level): | |
global current_sudoku_onboard | |
# generating sudoku for required level | |
current_sudoku_onboard = Sudoku().generate_sudoku(int(level)) | |
# drawing sudoku by calling javascript function from python | |
eel.draw_sudoku(current_sudoku_onboard) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Importing the progress bar library | |
from progress import Progress as P | |
import time | |
images = 2478 # number of images to process | |
# Create a progress bar instance | |
p = P(images,mode = 'no-bar') | |
# Creating one element for image counter | |
counter = P.Element("Images Processed", 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Importing the progress bar library | |
from progress import Progress as P | |
import time | |
import random | |
p = P(70, mode='bar') # progress bar object | |
# defining progress bar elements | |
epoch = P.Element("Epoch", 0) |
OlderNewer