コード例 #1
0
ファイル: NumTable.cs プロジェクト: RobertAlbus/number_grid
        public string Print(NumList list)
        {
            var listString = "";

            for (int i = 0; i < list.Length(); ++i)
            {
                listString += list[i];
            }

            return(listString);
        }
コード例 #2
0
        public NumList GenerateList(
            int length,
            int maxValue,
            int minValue)
        {
            var rand    = new Random();
            var numList = new NumList();

            for (var i = 0; i < length; ++i)
            {
                numList.Add(rand.Next(minValue, maxValue));
            }

            return(numList);
        }
コード例 #3
0
        public int LowestSum(NumList list, int quantityToSum)
        {
            var lowestSum = int.MaxValue;

            for (int offset = 0; offset + quantityToSum <= list.Length(); ++offset)
            {
                var currentSum = 0;

                for (int item = 0; item < quantityToSum; ++item)
                {
                    currentSum += list[offset + item];
                }

                if (currentSum < lowestSum)
                {
                    lowestSum = currentSum;
                }
            }

            return(lowestSum);
        }