“Isolate” specific Row/Column/Diagonal from a 64-bit number
Here’s a solution with only 4 main steps: const uint64_t column_mask = 0x8080808080808080ull; const uint64_t magic = 0x2040810204081ull; int get_col(uint64_t board, int col) { uint64_t column = (board << col) & column_mask; column *= magic; return (column >> 56) & 0xff; } It works like this: the board is shifted to align the column with … Read more