Example #1
0
        public static Result LatticePaths(Problem arguments)
        {
            ulong gridSize = arguments.BigNumber;

            var x
                = UtilityMath.FactorialOverFlow(gridSize);
            var y = UtilityMath.FactorialOverFlow(2 * gridSize);

            BigInteger a      = BigInteger.Parse(x);
            BigInteger b      = BigInteger.Parse(y);
            BigInteger n      = BigInteger.Pow(a, 2);
            BigInteger routes = BigInteger.Divide(b, n);

            var m = string.Format("There are {0} route(s) in a {1}x{1} grid.", routes, gridSize);
            var r = new Result(arguments.Id, m);

            return(r);
        }