summaryrefslogtreecommitdiff
path: root/capset.go
diff options
context:
space:
mode:
Diffstat (limited to 'capset.go')
-rw-r--r--capset.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/capset.go b/capset.go
index 3fcc814..ae77571 100644
--- a/capset.go
+++ b/capset.go
@@ -144,11 +144,16 @@ func (d *Deck) hasSetWithLast(tableau []Card) bool {
}
i := len(tableau) - 1
for j := 0; j < i; j++ {
+ // Both same and diff are trying to get 11 for each attribute to indicate a
+ // match.
same := ^(tableau[i].attrs ^ tableau[j].attrs)
diff := tableau[i].attrs ^ tableau[j].attrs
for k := j + 1; k < i; k++ {
+ // same and diff become fully computed. 11 indicates match.
sameFinal := same & ^(tableau[i].attrs ^ tableau[k].attrs)
diffFinal := diff ^ tableau[k].attrs
+ // Shift and AND so that we have a single bit to indicate success. This is
+ // necessary for the OR to function appropriately.
sameSingle := sameFinal & (sameFinal >> 1)
diffSingle := diffFinal & (diffFinal >> 1)
if (sameSingle|diffSingle)&d.isSetBitMask == d.isSetBitMask {