Sudoku – Test results

To make formatting on the results below we had to fool WordPress into thinking it was a big comment in Python code – so ignore the line numbers.

'''
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> 
=========== RESTART: D:/Py Pi Code and Docs/Sudoku/The Grid 120821.py ==========
Columns ***---1---***  ***---2---***  ***---3---***  ***---4---***  ***---5---***  ***---6---***  ***---7---***  ***---8---***  ***---9---*** 
Row1:  |      1       |      0       |      0       |      0       |      7       |      0       |      5       |      8       |      3      |
       ---------------------------------------------------------------------------------------------------------------------------------------
Row2:  |      0       |      2       |      0       |      9       |      0       |      0       |      6       |      0       |      0      |
       ---------------------------------------------------------------------------------------------------------------------------------------
Row3:  |      0       |      8       |      0       |      0       |      3       |      1       |      0       |      2       |      0      |
       ---------------------------------------------------------------------------------------------------------------------------------------
Row4:  |      0       |      0       |      0       |      4       |      1       |      0       |      0       |      0       |      0      |
       ---------------------------------------------------------------------------------------------------------------------------------------
Row5:  |      0       |      0       |      8       |      0       |      0       |      0       |      4       |      0       |      0      |
       ---------------------------------------------------------------------------------------------------------------------------------------
Row6:  |      0       |      0       |      0       |      0       |      8       |      6       |      0       |      0       |      0      |
       ---------------------------------------------------------------------------------------------------------------------------------------
Row7:  |      0       |      7       |      0       |      5       |      9       |      0       |      0       |      6       |      0      |
       ---------------------------------------------------------------------------------------------------------------------------------------
Row8:  |      0       |      0       |      3       |      0       |      0       |      7       |      0       |      9       |      0      |
       ---------------------------------------------------------------------------------------------------------------------------------------
Row9:  |      9       |      1       |      5       |      0       |      6       |      0       |      0       |      0       |      7      |
       ---------------------------------------------------------------------------------------------------------------------------------------

Testing functions to find used numbers in row 5, col 4, and calculated box 5
the box number named function yeilds: 5
the box number from a lambda yeilds: 5
row 5:  [4, 8]
col 4: [4, 5, 9]
box #5  boxnums are: [1, 4, 6, 8]

Test function to find possible values for a cell
for row 5 and col 4:   [2, 3, 7]  This is the single value or the inverse of the list of combined row, col and box values.

And here are all the possible values by row and column.

Columns ???---1---???  ???---2---???  ???---3---???  ???---4---???  ???---5---???  ???---6---???  ???---7---???  ???---8---???  ???---9---??? 
Row1:  |     [1]      |  [4, 6, 9]   |  [4, 6, 9]   |    [2, 6]    |     [7]      |    [2, 4]    |     [5]      |     [8]      |     [3]     |
       ---------------------------------------------------------------------------------------------------------------------------------------
Row2:  | [3, 4, 5, 7] |     [2]      |    [4, 7]    |     [9]      |    [4, 5]    |  [4, 5, 8]   |     [6]      |  [1, 4, 7]   |    [1, 4]   |
       ---------------------------------------------------------------------------------------------------------------------------------------
Row3:  | [4, 5, 6, 7] |     [8]      | [4, 6, 7, 9] |     [6]      |     [3]      |     [1]      |    [7, 9]    |     [2]      |    [4, 9]   |
       ---------------------------------------------------------------------------------------------------------------------------------------
Row4:  | [2, 3, 5, 6, 7] | [3, 5, 6, 9] | [2, 6, 7, 9] |     [4]      |     [1]      | [2, 3, 5, 9] | [2, 3, 7, 8, 9] |  [3, 5, 7]   | [2, 5, 6, 8, 9]|
       ---------------------------------------------------------------------------------------------------------------------------------------
Row5:  | [2, 3, 5, 6, 7] | [3, 5, 6, 9] |     [8]      |  [2, 3, 7]   |    [2, 5]    | [2, 3, 5, 9] |     [4]      | [1, 3, 5, 7] | [1, 2, 5, 6, 9]|
       ---------------------------------------------------------------------------------------------------------------------------------------
Row6:  | [2, 3, 4, 5, 7] | [3, 4, 5, 9] | [1, 2, 4, 7, 9] |  [2, 3, 7]   |     [8]      |     [6]      | [1, 2, 3, 7, 9] | [1, 3, 5, 7] | [1, 2, 5, 9]|
       ---------------------------------------------------------------------------------------------------------------------------------------
Row7:  |  [2, 4, 8]   |     [7]      |    [2, 4]    |     [5]      |     [9]      | [2, 3, 4, 8] | [1, 2, 3, 8] |     [6]      | [1, 2, 4, 8]|
       ---------------------------------------------------------------------------------------------------------------------------------------
Row8:  | [2, 4, 6, 8] |    [4, 6]    |     [3]      |  [1, 2, 8]   |    [2, 4]    |     [7]      |  [1, 2, 8]   |     [9]      | [1, 2, 4, 5, 8]|
       ---------------------------------------------------------------------------------------------------------------------------------------
Row9:  |     [9]      |     [1]      |     [5]      |  [2, 3, 8]   |     [6]      | [2, 3, 4, 8] |  [2, 3, 8]   |    [3, 4]    |     [7]     |
       ---------------------------------------------------------------------------------------------------------------------------------------

Testing posting a value - but cheating a little to make it a value
that will yeild a matching pair in column four.

We have a new board of possible values. Note many 2's are gone - except our post.
Notice the 3 & 7 pairs in column 4.  But an impossible 3 remains at R9C4,
Columns ???---1---???  ???---2---???  ???---3---???  ???---4---???  ???---5---???  ???---6---???  ???---7---???  ???---8---???  ???---9---??? 
Row1:  |     [1]      |  [4, 6, 9]   |  [4, 6, 9]   |     [2]      |     [7]      |     [4]      |     [5]      |     [8]      |     [3]     |
       ---------------------------------------------------------------------------------------------------------------------------------------
Row2:  | [3, 4, 5, 7] |     [2]      |    [4, 7]    |     [9]      |    [4, 5]    |  [4, 5, 8]   |     [6]      |  [1, 4, 7]   |    [1, 4]   |
       ---------------------------------------------------------------------------------------------------------------------------------------
Row3:  | [4, 5, 6, 7] |     [8]      | [4, 6, 7, 9] |     [6]      |     [3]      |     [1]      |    [7, 9]    |     [2]      |    [4, 9]   |
       ---------------------------------------------------------------------------------------------------------------------------------------
Row4:  | [2, 3, 5, 6, 7] | [3, 5, 6, 9] | [2, 6, 7, 9] |     [4]      |     [1]      | [2, 3, 5, 9] | [2, 3, 7, 8, 9] |  [3, 5, 7]   | [2, 5, 6, 8, 9]|
       ---------------------------------------------------------------------------------------------------------------------------------------
Row5:  | [2, 3, 5, 6, 7] | [3, 5, 6, 9] |     [8]      |    [3, 7]    |    [2, 5]    | [2, 3, 5, 9] |     [4]      | [1, 3, 5, 7] | [1, 2, 5, 6, 9]|
       ---------------------------------------------------------------------------------------------------------------------------------------
Row6:  | [2, 3, 4, 5, 7] | [3, 4, 5, 9] | [1, 2, 4, 7, 9] |    [3, 7]    |     [8]      |     [6]      | [1, 2, 3, 7, 9] | [1, 3, 5, 7] | [1, 2, 5, 9]|
       ---------------------------------------------------------------------------------------------------------------------------------------
Row7:  |  [2, 4, 8]   |     [7]      |    [2, 4]    |     [5]      |     [9]      | [2, 3, 4, 8] | [1, 2, 3, 8] |     [6]      | [1, 2, 4, 8]|
       ---------------------------------------------------------------------------------------------------------------------------------------
Row8:  | [2, 4, 6, 8] |    [4, 6]    |     [3]      |    [1, 8]    |    [2, 4]    |     [7]      |  [1, 2, 8]   |     [9]      | [1, 2, 4, 5, 8]|
       ---------------------------------------------------------------------------------------------------------------------------------------
Row9:  |     [9]      |     [1]      |     [5]      |    [3, 8]    |     [6]      | [2, 3, 4, 8] |  [2, 3, 8]   |    [3, 4]    |     [7]     |
       ---------------------------------------------------------------------------------------------------------------------------------------

Now testing mpair_cols to demo how this function could be critical to solving a puzzle.
In this example test we are only testing col 4 - in practice we would test all columns.
This call results in finding a matched pair of [3,7] which means 3's and 7's should be 
removed from any non-matched-pair cells - they are 'impossible numbers'.

Columns ???---1---???  ???---2---???  ???---3---???  ???---4---???  ???---5---???  ???---6---???  ???---7---???  ???---8---???  ???---9---??? 
Row1:  |     [1]      |  [4, 6, 9]   |  [4, 6, 9]   |     [2]      |     [7]      |     [4]      |     [5]      |     [8]      |     [3]     |
       ---------------------------------------------------------------------------------------------------------------------------------------
Row2:  | [3, 4, 5, 7] |     [2]      |    [4, 7]    |     [9]      |    [4, 5]    |  [4, 5, 8]   |     [6]      |  [1, 4, 7]   |    [1, 4]   |
       ---------------------------------------------------------------------------------------------------------------------------------------
Row3:  | [4, 5, 6, 7] |     [8]      | [4, 6, 7, 9] |     [6]      |     [3]      |     [1]      |    [7, 9]    |     [2]      |    [4, 9]   |
       ---------------------------------------------------------------------------------------------------------------------------------------
Row4:  | [2, 3, 5, 6, 7] | [3, 5, 6, 9] | [2, 6, 7, 9] |     [4]      |     [1]      | [2, 3, 5, 9] | [2, 3, 7, 8, 9] |  [3, 5, 7]   | [2, 5, 6, 8, 9]|
       ---------------------------------------------------------------------------------------------------------------------------------------
Row5:  | [2, 3, 5, 6, 7] | [3, 5, 6, 9] |     [8]      |    [3, 7]    |    [2, 5]    | [2, 3, 5, 9] |     [4]      | [1, 3, 5, 7] | [1, 2, 5, 6, 9]|
       ---------------------------------------------------------------------------------------------------------------------------------------
Row6:  | [2, 3, 4, 5, 7] | [3, 4, 5, 9] | [1, 2, 4, 7, 9] |    [3, 7]    |     [8]      |     [6]      | [1, 2, 3, 7, 9] | [1, 3, 5, 7] | [1, 2, 5, 9]|
       ---------------------------------------------------------------------------------------------------------------------------------------
Row7:  |  [2, 4, 8]   |     [7]      |    [2, 4]    |     [5]      |     [9]      | [2, 3, 4, 8] | [1, 2, 3, 8] |     [6]      | [1, 2, 4, 8]|
       ---------------------------------------------------------------------------------------------------------------------------------------
Row8:  | [2, 4, 6, 8] |    [4, 6]    |     [3]      |    [1, 8]    |    [2, 4]    |     [7]      |  [1, 2, 8]   |     [9]      | [1, 2, 4, 5, 8]|
       ---------------------------------------------------------------------------------------------------------------------------------------
Row9:  |     [9]      |     [1]      |     [5]      |     [8]      |     [6]      | [2, 3, 4, 8] |  [2, 3, 8]   |    [3, 4]    |     [7]     |
       ---------------------------------------------------------------------------------------------------------------------------------------
Note that r9c4 used to have [3,8] but now shows only 8.  This revealed single could now be posted in t_posted.
Depending on how you wanted your game to flow, you could let the user do this or you could write code or
alter a function to remove any discovered single automatically.

Now lets reset the possible values and run mpair_cols on all the columns
for col #1 numbers to remove are: []
for col #2 numbers to remove are: []
for col #3 numbers to remove are: []
for col #4 numbers to remove are: [3]
for col #5 numbers to remove are: []
for col #6 numbers to remove are: []
for col #7 numbers to remove are: []
for col #8 numbers to remove are: []
for col #9 numbers to remove are: []

Columns ???---1---???  ???---2---???  ???---3---???  ???---4---???  ???---5---???  ???---6---???  ???---7---???  ???---8---???  ???---9---??? 
Row1:  |     [1]      |  [4, 6, 9]   |  [4, 6, 9]   |     [2]      |     [7]      |     [4]      |     [5]      |     [8]      |     [3]     |
       ---------------------------------------------------------------------------------------------------------------------------------------
Row2:  | [3, 4, 5, 7] |     [2]      |    [4, 7]    |     [9]      |    [4, 5]    |  [4, 5, 8]   |     [6]      |  [1, 4, 7]   |    [1, 4]   |
       ---------------------------------------------------------------------------------------------------------------------------------------
Row3:  | [4, 5, 6, 7] |     [8]      | [4, 6, 7, 9] |     [6]      |     [3]      |     [1]      |    [7, 9]    |     [2]      |    [4, 9]   |
       ---------------------------------------------------------------------------------------------------------------------------------------
Row4:  | [2, 3, 5, 6, 7] | [3, 5, 6, 9] | [2, 6, 7, 9] |     [4]      |     [1]      | [2, 3, 5, 9] | [2, 3, 7, 8, 9] |  [3, 5, 7]   | [2, 5, 6, 8, 9]|
       ---------------------------------------------------------------------------------------------------------------------------------------
Row5:  | [2, 3, 5, 6, 7] | [3, 5, 6, 9] |     [8]      |    [3, 7]    |    [2, 5]    | [2, 3, 5, 9] |     [4]      | [1, 3, 5, 7] | [1, 2, 5, 6, 9]|
       ---------------------------------------------------------------------------------------------------------------------------------------
Row6:  | [2, 3, 4, 5, 7] | [3, 4, 5, 9] | [1, 2, 4, 7, 9] |    [3, 7]    |     [8]      |     [6]      | [1, 2, 3, 7, 9] | [1, 3, 5, 7] | [1, 2, 5, 9]|
       ---------------------------------------------------------------------------------------------------------------------------------------
Row7:  |  [2, 4, 8]   |     [7]      |    [2, 4]    |     [5]      |     [9]      | [2, 3, 4, 8] | [1, 2, 3, 8] |     [6]      | [1, 2, 4, 8]|
       ---------------------------------------------------------------------------------------------------------------------------------------
Row8:  | [2, 4, 6, 8] |    [4, 6]    |     [3]      |    [1, 8]    |    [2, 4]    |     [7]      |  [1, 2, 8]   |     [9]      | [1, 2, 4, 5, 8]|
       ---------------------------------------------------------------------------------------------------------------------------------------
Row9:  |     [9]      |     [1]      |     [5]      |     [8]      |     [6]      | [2, 3, 4, 8] |  [2, 3, 8]   |    [3, 4]    |     [7]     |
       ---------------------------------------------------------------------------------------------------------------------------------------

Special Reminder - none of these impossible number removals are permanent!  If we wanted to lock in a single
that is revealed by impossible numbers removed we would create code to compare the output of print_pv_board with
the data output after board_pv is called (which would return us to our starting state) and post any 'new' singles.
>>> 
,,,