Example #1
0
        static BigInteger CombinationsForPieces(Available available, int pieces, int maxSquares, Func <Available, BigInteger> downStream)
        {
            BigInteger sum = 0;

            for (int i = 0; i <= pieces; i++)
            {
                Available nextAvailable = available.Minus(i);

                int squares = Math.Min(nextAvailable.Squares, maxSquares);

                long combinations = Maths.Combinations(squares, pieces);

                BigInteger mult = downStream(nextAvailable);

                BigInteger xy = combinations * mult;

                sum = sum + xy;
            }

            return(sum);
        }
Example #2
0
        static void Main(string [] args)
        {
            Func <Available, BigInteger> fn = x => 1;

            fn = Pawns(fn);                              // pawn
            fn = BlackAndWhite(GenericPiece(1), fn);     // queen
            fn = BlackAndWhite(GenericPiece(2), fn);     // knight
            fn = BlackAndWhite(GenericPiece(1, 32), fn); // black-square bishop
            fn = BlackAndWhite(GenericPiece(1, 32), fn); // white-square bishop
            fn = KingsAndRooks(fn);

            Available available = new Available {
                BlackSquares = 32, WhiteSquares = 32
            };
            // 2* - white or black to play
            BigInteger result = 2 * fn(available);

            Console.WriteLine(result);
            Console.WriteLine(result.ToString().Length + " digits");
            Maths.Display(result, 10);
            Maths.Display(result, 2);
        }