def allPossibleGrids():
    allPossiblestxt = open(
        "/Users/markhauenstein/PycharmProjects/SudokuSolver/allPossibles.txt",
        mode='w')
    validGrids = []
    i = 0
    for TL in range(1, 10):
        for TM in range(1, 10):
            for TR in range(1, 10):
                for ML in range(1, 10):
                    for MM in range(1, 10):
                        for MR in range(1, 10):
                            for BL in range(1, 10):
                                for BM in range(1, 10):
                                    for BR in range(1, 10):
                                        i += 1
                                        if Grids.Grid(TL, TM, TR, ML, MM, MR,
                                                      BL, BM, BR).isValid:
                                            print(i, "|||", TL, TM, TR, ML, MM,
                                                  MR, BL, BM, BR)
                                            validGrids.append(
                                                Grids.Grid(
                                                    TL, TM, TR, ML, MM, MR, BL,
                                                    BM, BR))
                                            allPossiblestxt.write(
                                                str(TL) + str(TM) + str(TR) +
                                                str(ML) + str(MM) + str(MR) +
                                                str(BL) + str(BM) + str(BR) +
                                                "\n")
    allPossiblestxt.close()
    return validGrids
Beispiel #2
0
import Grids as Grids

with open("/Users/markhauenstein/PycharmProjects/SudokuSolver/input.txt",
          mode='rt') as inputTxt:
    inputArr = inputTxt.readlines()

TL = Grids.Grid(inputArr[0], "Top Left")
TM = Grids.Grid(inputArr[1], "Top Middle")
TR = Grids.Grid(inputArr[2], "Top Right")
ML = Grids.Grid(inputArr[3], "Middle Left")
MM = Grids.Grid(inputArr[4], "Middle Middle")
MR = Grids.Grid(inputArr[5], "Middle Right")
BL = Grids.Grid(inputArr[6], "Bottom Left")
BM = Grids.Grid(inputArr[7], "Bottom Middle")
BR = Grids.Grid(inputArr[8], "Bottom Right")

bigGrid = Grids.BigGrid(TL, TM, TR, ML, MM, MR, BL, BM, BR)

for TL in TL.validGrids:
    for TM in TM.validGrids:
        for TR in TR.validGrids:
            for ML in ML.validGrids:
                for MM in MM.validGrids:
                    for MR in MR.validGrids:
                        for BL in BL.validGrids:
                            for BM in BM.validGrids:
                                for BR in BR.validGrids:
                                    if Grids.BigGrid(TL, TM, TR, ML, MM, MR,
                                                     BL, BM, BR).allGridsValid:
                                        print((TL.contents, TM.contents,
                                               TR.contents, ML.contents,