Condense Array to Number
Reads an array of integers and condense them by summing adjacent couples of elements until a single integer is obtained:
2 10 3 2 4 1 2 5 0 4 1 2
12 13 6 5 3 5 4 5 3
25 11 8 9 9 8
19 18 17
35
int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            while (nums.Length > 1)
            {
                int[] condensed = new int[nums.Length - 1];
                for (int left = 0; left < nums.Length - 1; left++)
                {
                    for (int right = left+1; right < nums.Length; right++)
                    {
                        var sum = nums[left] + nums[right];
                        condensed[sum] = sum;
                        nums = condensed;
                    }
        
                }
            }
            Console.WriteLine(nums[0]);
Това е една от задачите за домашно, Не мога да съставя правилно алгоритъма по който да събира числата. Ще се радвам, ако ударите едно рамо ! ;)
Ето го цялото ми решение, дава 100/100:
int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var counter = input.Length;
while (counter>1)
{
for (int i = 0; i < input.Length - 1; i++)
{
input[i] = input[i] + input[i + 1];
}
counter--;
}
Console.WriteLine(input[0]);
@DimoYordanov
Само не разбирам защо печаташ първия индекс долу?