Do you know where your variables are? | |
PerlMonks |
Re^2: Efficient enumeration of pandigital fractionsby LanX (Saint) |
on Jul 21, 2018 at 13:18 UTC ( [id://1219003]=note: print w/replies, xml ) | Need Help?? |
in hindsight, in an implementation I'd
==== for instance if you decide to go from left to right left with $i=4 i * efgh = abcd the multiplication table would look like
( update when going from left to right you have to also put 7 into @carry3, because 28 could add to a former carry. going from right to left is indeed easier ...) ==== after trying $e=1 you know that @remaing=(2,3,5,6,7,8,9) => $remaining = vec(111110110) $a = $i*$e + carry(4*f) = 4*1 + range(0..3) the carry range filter for 0..3 is vec(1111) shifted accordingly for 4 is $carryrange=vec(1111000) $remaining & $carryrange = vec(1110000) => possible $a are in (5,6,7) => carry=0 is (obviously) forbidden $remaining & ($carry1 | $carry2 | $carry3) = vec(111110100) => possible $f are in (9,8,7,6,5,3) using this approach has several advantages
this approach will lead to a very efficient branch and bound already, I'm confident you can find even more "filter rules" to bound more efficiently.
Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|