It turns out coding a general "Aligned Pair Exclusion" is fairly straight forward. The trick is realizing that the eliminations occur for a candidate from one cell when each pair formed by that candidate combined with each candidate from the other cell is contained within an ALS seen by both cells. If the cells share a house, then if the candidate is in both cells, it can be ignored. If the cells don't, then the elimination of that candidate is not valid with this technique. Here is an example of a 3-cell ALS "Unaligned Pair Exclusion" using cells r3c7 & r8c9 and two ALS (r789c7, r2c9):
- Code: Select all
4-value Aligned Pair (r789c7, r2c9): : r3c7|r8c9 => r3c7<>4
+-------------------+----------------+----------------------+
| 128 18 7 | 4 689 3 | 5 2689 269 |
| 9 358 3458 | 7 568 2 | 348 1 @46 |
| 258 6 345 | 589 589 1 | -234789 2489 2479 |
+-------------------+----------------+----------------------+
| 6 158 2 | 3 14 9 | 48 7 45 |
| 58 4 3589 | 256 257 67 | 1 289 2359 |
| 157 13579 359 | 25 14 8 | 6 249 23459 |
+-------------------+----------------+----------------------+
| 3 789 689 | 289 2789 5 | #2479 2469 1 |
| 578 5789 5689 | 1 2789 4 | #279 3 *2679 |
| 4 2 1 | 69 3 67 | #79 5 8 |
+-------------------+----------------+----------------------+
In this example, based on previous technique descriptions, one would 1) write down the 24 possible pairs between candidates in cells r3c7 & r8c9, 2) eliminate those which are contained in a common ALS or have the same candidate, and 3) determine if eliminations had occurred. What I implemented was to look at each of the 4 possible pairs using one candidate from r3c7 or the 6 possible pairs using one candidate from r8c9, 2) determine if all the pairs are contained in one of the common ALSs or have the same candidate in a common house, and 3) if so then eliminate the candidate. In the above example {(4,2), (4,6), (4,7), (4,9)} are all contained in one or the other of the ALSs so 4 can be eliminated. Its pretty obvious with this approach that not all of the cells of the ALS need to be seen by the candidate cell, only those cells of the ALS which contain the candidate.
Maybe APE should be redefined to be "ALS Pair Exclusion"?
Note that the same exclusion (r3c7<>4) above can be made with a VWXYZ-wing. In the past the conclusion was that APEs were a subset of ALSs exclusions. Maybe I'll look at that in the next couple of days.