예제 #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>	Handles the prime chain of step 5. </summary>
        ///
        /// <remarks>	Darrell Plank, 5/27/2020. </remarks>
        ///
        /// <param name="firstPrime">	The first prime to start the chain. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        private void HandlePrimeChain(GridLocation firstPrime)
        {
            var curPrimeLoc = firstPrime;
            var curStarLoc  = GetStarInColumn(curPrimeLoc.Col);

            StarZero(curPrimeLoc);

            while (!curStarLoc.IsNoLoc())
            {
                _rowStars[curStarLoc.Row] = -1;
                curPrimeLoc = new GridLocation(curStarLoc.Row, _rowPrimes[curStarLoc.Row]);
                curStarLoc  = GetStarInColumn(curPrimeLoc.Col);
                StarZero(curPrimeLoc);
            }
        }
            internal static bool IsClear(GridLocation pos)
            {
                var x = pos.Col;
                var y = pos.Row;

                if (_mapClear[x] == null)
                {
                    _mapClear[x] = new bool?[1000];
                }

                if (!_mapClear[x][y].HasValue)
                {
                    var val = (ulong)(x * x + 3 * x + 2 * x * y + y + y * y + _favorite);
                    _mapClear[x][y] = (Bitops.BitCount(val) & 1) == 0;
                }
                return(_mapClear[x][y].Value);
            }
예제 #3
0
 private void StarZero(GridLocation loc)
 {
     // Step 2
     _rowStars[loc.Row] = loc.Col;
 }
 internal Position(GridLocation location)
 {
     _location = location;
 }