コード例 #1
0
        public BinairoRowSolver(int size)
        {
            allDoneMask = size.ToMask();
            BitCounter bitCounter = new BitCounter();

            this.Add(new OpenStartDuosSolver());
            this.Add(new OpenEndDuosSolver());
            this.Add(new HoleAtStartSolver());
            this.Add(new HoleAtEndSolver());
            this.Add(new SingleHoleSolver());
            this.Add(new ZerosAllDoneSolver(bitCounter));
            this.Add(new OnesAllDoneSolver(bitCounter));
            this.Add(new ThreeHoleSolver(bitCounter));
            this.Add(new FourHoleSolver(bitCounter));
            //this.Add(new FiveHoleSolver(bitCounter));
        }
コード例 #2
0
        public bool Solve(ref ushort row, ref ushort mask, int size)
        {
            // check if hole is at start
            ushort firstOneMask = 0b1000_0000_0000_0000;
            ushort fullMask     = size.ToMask();

            if ((mask | firstOneMask) == fullMask)
            {
                var bitCounter = new BitCounter();
                int countOnes  = bitCounter.CountOnes(row, size);
                if (countOnes < size / 2)
                {
                    row |= firstOneMask;
                }
                mask |= firstOneMask;
                return(true);
            }
            return(false);
        }
コード例 #3
0
 public DuplicateRowSolver(int size, BitCounter counter)
 {
     fullMask        = size.ToMask();
     this.bitCounter = counter;
 }