Ad

Works for unknown number of int[]

Code
Diff
  • using System;
    using System.Linq;
    
    public static class Kata
    {
      public static int ArraySum(params int[][] arrs)
      {
        int sum = 0;
        foreach (int[] arr in arrs)
        {
            sum += arr.Sum();
        }
        return sum;
      }
    }
    
    • using System;
    • using System;
    • using System.Linq;
    • public static class Kata
    • {
    • public static int ArraySum(int[] arr1, int[] arr2, int[] arr3)
    • {
    • int[] newArray1 = arr1.Concat(arr2).ToArray();
    • int[] newArray2 = newArray1.Concat(arr3).ToArray();
    • int sum = newArray2.Sum();
    • return sum;
    • }
    • public static class Kata
    • {
    • public static int ArraySum(params int[][] arrs)
    • {
    • int sum = 0;
    • foreach (int[] arr in arrs)
    • {
    • sum += arr.Sum();
    • }
    • return sum;
    • }
    • }