Package: Matrix - the traditional programming method

This is the traditional method to solve the Sudoku.

matrix.matrix.CheckInObvious(m, n, p, amt=0)[source]

Checking the number in every two different position can decide the number in other box which does not have the number yet Parameters: groups: [((x,0)|(0,y), [(x1,y1),(x2,y2)...]),...]

matrix.matrix.CheckObvious(m, n, p, amt=0)[source]

Checking the every number in every two different position can descide the number in other box which does not have the number yet

matrix.matrix.CheckObviousByOne(m, n, p, amt=0)[source]

Checking every number with only one assigned numer or a group number to decide the number in other box which does not have the number yet

matrix.matrix.CheckOnlyOnePossible(m, n, p, amt=0)[source]

Checking the position which only has one possible value

matrix.matrix.CheckOnlyOnePossibleByNum(m, n, p, amt=0)[source]

Check if there is only one number left in the same x, y or box

matrix.matrix.CheckOnlyOnePossibleByPos(m, n, p, amt=0)[source]

Checking the same positions is only one possible for the number

matrix.matrix.CheckResultByTwoPossibleVal(m, n, p, r0, r1, logic='CheckResultByTwoPossible')[source]

Check two emulate result records from a number only have two possible position in a box, line; or a postion only have two possible numbers, if they have same record or not!

matrix.matrix.CheckVal(m, pos, v)[source]

Check if one of the positions has been set the value

matrix.matrix.Emulator(m, n, p, pos, v, targets=, []checkval=0)[source]

emulate the pos to be set v, then start to use some basic methods to try to solve it will stop when and return:: 1: one of the targets have been set the checkval 2: isDone -1: error is True 0: all basic methods have been tested, and can’t solve and the result matrix

matrix.matrix.GetAllPosInBox(m, p, b, method='a', num=0, diff=[])[source]

Getting a box’s all position method: a: all, s: all assigned, u: all un-assigned num: 0(1-9), if method=”u”, if the num is 1-9, it will only take the positions that is possible be filled by the num diff: the posithon in diff must be excluded

matrix.matrix.GetAllPosOfX(m, p, idx, diff=, []method='a', num=0)[source]

Get all other possition of line from x = idx than those in diff method: a: all, s:has assigned, u:not assigned num: if method is u and set the number to 1-9, will get all possible pos which are possible to be assigned the num

matrix.matrix.GetAllPosOfY(m, p, idx, diff=, []method='a', num=0)[source]

Get all other possition of line from y = idx than those in diff method: a: all, s:has assigned, u:not assigned num: if method is u and set the number to 1-9, will get all possible pos which are possible to be assigned the num

matrix.matrix.GetCanNotSeenInBox(m, b, p1, p2)[source]

get the postions in a box(b) which can not be seen in position p1 and p2 which are in the same box and those positions are not filled p1, p2 must be in different x and y, p1, p2 sometime as the form (x,0)|(0,y)

matrix.matrix.GetChains(m, n, p, Pos, numbers=2)[source]

Get numbers Chains from a Pos list return: [([num1, num2,...], [pos1, pos2,...]),...]

matrix.matrix.GetEffectBox(p1, p2)[source]

get Boxes Position(i, j) list from two positions which will effect these boxes

matrix.matrix.GetEffectBoxByOne(p1)[source]

get Boxes Position(i, j) list by one positions which will effect these boxes

matrix.matrix.GetEffectBoxByOneDir(grp)[source]

get Boxes Position(i, j) list by one group which will effect these boxes

matrix.matrix.GetEffectBoxByOnePosAndOneDir(p1, p2, grp)[source]

get Boxes Position(i, j) list from one position and one group which will effect these boxes but only get same x or same y box grp: (x,0)|((0,y)

matrix.matrix.GetEffectBoxByTwoGrp(p1, p2, d1, d2)[source]

get Boxes Position(i, j) list by two directed group which will effect these boxes p1, p2: any position of those groups to make sure the whichbox d1, d2: format like (x,0) or (0, y) to say the group’s direction

matrix.matrix.GetGroupInBox(m, n, p, number)[source]

Get the number Groups which are formed natually in a box because the remain possible positions can at the same line

matrix.matrix.GetIndirectNumberInBox(possiblePos)[source]

Get Indirect Number Group in a box by possible positions of a number judge by if all ther possiblePos has a same direction, means that those have same x or y if so, it will return (x, 0) or (0, y), otherwise will return (0, 0)

matrix.matrix.GetNotAssignedByX(m, x)[source]

Get not yet be assigned positions and number by x

matrix.matrix.GetSameBoxOtherPos(m, p, pos)[source]

get the other postions in a box which there is a postion of x, y

matrix.matrix.ReduceByBoxChain(m, n, p)[source]

Reduce By Box’s chaing

matrix.matrix.ReduceByBoxGroup(m, n, p)[source]

Reduce Method #1: Reduce by the group number in a box

matrix.matrix.ReduceByChain(m, n, p, numbers, pos, chainpos, logic='Reduced By Chain')[source]

Reduce numbers of positions of pos which other than positions of chainpos

matrix.matrix.ReduceByEmuResult(m, n, p, m1, possible, v)[source]

Reduce v from some postions by emulate result m1

matrix.matrix.ReduceByLineChain(m, n, p, direction='x')[source]

Reduce By Line chain direction: x: the same x postions, y: the same y positions

matrix.matrix.ReduceByTwoPositionInBox(m, n, p)[source]

Reduce by two postions which in the same box or same line, and have a common possible number which only be possible in these two different positions we assume the position set the first, then test the second number where the first number in of the same box, samy x, and same y if we can get the number in the other position, we can make sure that in the other positions will not have the first number because both of two possible number have been tested. return: reduces, sets

matrix.matrix.ReduceByTwoPositionOfLine(m, n, p, direction='x')[source]

Reduce by two postions which in the same line, and have a common possible number which only be possible in these two different positions we assume the position set the first, then test the second number where the first number in of the same box, samy x, and same y if we can get the number in the other position, we can make sure that in the other positions will not have the first number because both of two possible number have been tested. return: reduces, sets

matrix.matrix.ReduceByTwoPossible(m, n, p)[source]

Reduce by a postion’s two possible number we assume the position set the first, then test the second number where the first number in of the same box, samy x, and same y if we can get the number in the other position, we can make sure that in the other positions will not have the first number because both of two possible number have been tested. return: reduces, sets

matrix.matrix.SortedUnAssignedPosByPossibles(m, p, possibles=0)[source]

Get unassign position’s possible number list, format is [(p1,[n1,n2,...]),(p2,[n1, n2,...]),...] and Sorted By the possible numbers possibles: 0 for all, >=2, mean get only the possible numbers for it

matrix.matrix.TryError(file=None, m=, []n=, []p=, []depth=0)[source]

Try Error method

matrix.matrix.WhichBox(pos)[source]

get a Box Postion(i, j) from a position (x, y)

matrix.matrix.emptyMatrix()[source]

init the matrix return:: m: matrix map n: the number’s position, the first element save the numbers p: the possible numbers in every position

matrix.matrix.fillLastNumberByBox(m, n, p, box)[source]

fill the Box’s last number

matrix.matrix.fillLastNumberByX(m, n, p, i)[source]

fill the x line’s last number

matrix.matrix.fillLastNumberByY(m, n, p, i)[source]

fill the y line’s last number

matrix.matrix.isDone(m)[source]

Checking the Matrix is done or not

matrix.matrix.isInBox(m, p, b, number)[source]

Check the number is filled in a box (i, j)

matrix.matrix.isPossible(m, p, pos, v, groups=[])[source]

Check if the value v is possible at pos(x, y)

matrix.matrix.isPossibleByBox(m, p, pos, v, groups=[])[source]

Check the same box if the value v is possible at pos(x, y)

matrix.matrix.isPossibleByX(m, pos, v, groups=[])[source]

Check the same x if the value v is possible at pos(x, y)

matrix.matrix.isPossibleByY(m, pos, v, groups=[])[source]

Check the same y if the value v is possible at pos(x, y) if group number has passed, should check box group number

matrix.matrix.main(file, methods=0)[source]

main program

matrix.matrix.printMatrix(m)[source]

print matrix(m)

matrix.matrix.readDefine(file, m, n, p)[source]

Reading the Matrix form a define file, the format must be as x,y,v Save the file by the Unix text format

matrix.matrix.reduceNumber(m, n, p, pos, v, logic='defined')[source]

Reduce the possible number of the position x, y from v return: 0: Error, 1:reduce, 2:reduce and only one value left, so set the number

matrix.matrix.setNumber(m, n, p, pos, v, logic='defined')[source]

Setting the position x, y to be number v

Previous topic

Package: Sudoku - the OOP method

This Page