On Feb 9, 8:47*am, Kaz Kylheku <kkylh...@gmail.com> wrote:
> > y = x & (x >> H0);
> > if (y & (y >> 2 * H0))
> > return 1;
> The test looks for the presence of triplets of equally spaced
> integers, where the spacing is H0.
Check again! First y finds pairs;
second y finds ... quadruplets!
In the original source code (from a famous benchmark)
each
if (R)
actually has the form
if ((R) != 0)
At the last moment before posting I deleted the
"unnecessary" ( ... != 0)
to reduce clutter. I was overzealous
> However, this set doesn't necessarily fit into the return type
> (assuming that the uint64 typedef name, in good faith, represents some
> kind of 64 bit or perhaps wider type). This is a bug; perhaps the
> intent was: return (y & (y >> 2)) != 0;
Good catch, Kaz! I've been running this routine a lot
lately; but fortunately the real bug-free code, not
the zealously decluttered version I posted.
Thus the code checks for quadruplets aligned along
any of four axes. This could be a 4-D modelling but
in fact is a 2-D structure with diagonals, rows
and columns producing 4 axes. Application?
Hasbro's game Connect Four.
James