srikumarks / FD.js

Finite domain constraint programming library in JS
62 stars 6 forks source link

domain_complement bug #5

Closed pvdz closed 8 years ago

pvdz commented 8 years ago

It's probably a typo, yet weird that this doesn't trip anyone up.

https://github.com/srikumarks/FD.js/blob/master/fd.js#L190

            for (i = 0, len = d.length; i < len; ++i) {
                if (end < d[i][0]) {
                    result.push([end, d[i][0] - 1]);
                }
                end = d[0][1] + 1;
            }

In this part end is updated to d[0][1]+1 but d[0][1] never changes, and so the assignment is kind of a dud. I'm pretty sure this should be d[i][1]+1.

The problem becomes apparent when using domains of more than one interval with this function.