title: Sum Matrix Element Absolute Difference Row Column Numbers 2
signature: func sumMatrixElementAbsoluteDifferenceRowColumnNumbers2(n int) int {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual int, expected int) bool {
      return reflect.DeepEqual(actual,expected)
  }
  
  func driver(n int, expected int) string {
      if validateSolution(PLACEHOLDER_FN_NAME(n),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(12, 572)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(89, 234960)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(76, 146300)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(2, 2)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(81, 177120)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(11, 440)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(26, 5850)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(35, 14280)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(16, 1360)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(66, 95810)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
source_py: def sum_matrix_element_absolute_difference_row_column_numbers_2(n):
      n -= 1
      sum = 0
      sum += ((n * (n + 1)) / 2)
      sum += (((n * (n + 1)) * ((2 * n) + 1)) / 6)
      return int(sum)
source_cpp: int sum_matrix_element_absolute_difference_row_column_numbers_2(int n) {
    n --;
    int sum = 0;
    sum += ( n * ( n + 1 ) ) / 2;
    sum += ( n * ( n + 1 ) * ( 2 * n + 1 ) ) / 6;
    return sum;
  }