• + 0 comments

    in c#

    List> arr = new List>();

        for (int i = 0; i < 6; i++)
        {
            arr.Add(Console.ReadLine().TrimEnd()
                        .Split(' ')
                         .ToList()
                         .Select(arrTemp => Convert.ToInt32(arrTemp))
                         .ToList());
        }
    
       List<List<int>> result = new List<List<int>>();
       int indexNumber=0;
       int lenght_arr=arr[0].Count();
    
       for(int i=0; i<=3;i++)
       {
           for(int j=0; j<= lenght_arr-3;j++)
           {
              if(result.Count <= indexNumber) 
              {
                  result.Insert(indexNumber,new List<int>());
              }
    
               result[indexNumber].AddRange(arr[i].Skip(j).Take(3).ToList());
               result[indexNumber].AddRange(arr[i+1].Skip(j+1).Take(1).ToList());
               result[indexNumber].AddRange(arr[i+2].Skip(j).Take(3).ToList());
    
               indexNumber++;
           }
    
       }
    
       int maxnumber=result.Select(x=>x.Sum()).Max();
    
           Console.WriteLine(maxnumber);