示例#1
0
        public static Result LargeSum(Problem arguments)
        {
            string m;
            string sequence = arguments.Sequence;
            int    digits   = Convert.ToInt32(arguments.LongNumber);

            string[] numbers = sequence.Split(',').ToArray <string>();
            int      height  = numbers.Length;
            int      width   = numbers[0].Length;

            int[,] matrix = UtilityMath.LoadMatrix(numbers, height, width);
            string sum = UtilityMath.AddMatrix(matrix);

            if (digits < sum.Length)
            {
                m = string.Format("The first {0} digits of the large sum are {1}.", digits, sum.Substring(0, digits));
            }
            else
            {
                m = "Error: not enough digits specified.";
            }
            var r = new Result(arguments.Id, m);

            return(r);
        }