title: Sum Series 12 32 52 2N 12
signature: function sum_series_12_32_52_2n_12(n)
source_py: def sum_series_12_32_52_2n_12(n):
      sum = 0
      for i in range(1, (n + 1)):
          sum = (sum + (((2 * i) - 1) * ((2 * i) - 1)))
      return sum
source_cpp: int sum_series_12_32_52_2n_12(int n) {
    int sum = 0;
    for ( int i = 1;
    i <= n;
    i ++ ) sum = sum + ( 2 * i - 1 ) * ( 2 * i - 1 );
    return sum;
  }
question_info.test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(n) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver(14, 3654)
      print(string.format("TEST-0...%s",result))
  
      result = driver(61, 302621)
      print(string.format("TEST-1...%s",result))
  
      result = driver(37, 67525)
      print(string.format("TEST-2...%s",result))
  
      result = driver(86, 848046)
      print(string.format("TEST-3...%s",result))
  
      result = driver(47, 138415)
      print(string.format("TEST-4...%s",result))
  
      result = driver(98, 1254890)
      print(string.format("TEST-5...%s",result))
  
      result = driver(70, 457310)
      print(string.format("TEST-6...%s",result))
  
      result = driver(24, 18424)
      print(string.format("TEST-7...%s",result))
  
      result = driver(76, 585276)
      print(string.format("TEST-8...%s",result))
  
      result = driver(24, 18424)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 3654, "inputs": {"n": 14}}, {"idx": 1, "outputs": 302621, "inputs": {"n": 61}}, {"idx": 2, "outputs": 67525, "inputs": {"n": 37}}, {"idx": 3, "outputs": 848046, "inputs": {"n": 86}}, {"idx": 4, "outputs": 138415, "inputs": {"n": 47}}, {"idx": 5, "outputs": 1254890, "inputs": {"n": 98}}, {"idx": 6, "outputs": 457310, "inputs": {"n": 70}}, {"idx": 7, "outputs": 18424, "inputs": {"n": 24}}, {"idx": 8, "outputs": 585276, "inputs": {"n": 76}}, {"idx": 9, "outputs": 18424, "inputs": {"n": 24}}]
question_info.extension: lua
question_info.entry_fn_name: sum_series_12_32_52_2n_12
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__