algorithm initially build array without horizontal and vertical crossing