title: Number Triangles N Moves
signature: function number_triangles_n_moves(n)
source_py: def number_triangles_n_moves(n):
      answer = ([None] * (n + 1))
      answer[0] = 1
      i = 1
      while (i <= n):
          answer[i] = ((answer[(i - 1)] * 3) + 2)
          i = (i + 1)
      return answer[n]
source_cpp: int number_triangles_n_moves(int n) {
    int answer [ n + 1 ] = {
      0 };
      answer [ 0 ] = 1;
      for ( int i = 1;
      i <= n;
      i ++ ) answer [ i ] = answer [ i - 1 ] * 3 + 2;
      return answer [ n ];
    }
question_info.entry_fn_name: number_triangles_n_moves
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0', '1', '2']
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(33, 11118121133111045)
      print(string.format("TEST-0...%s",result))
  
      result = driver(8, 13121)
      print(string.format("TEST-1...%s",result))
  
      result = driver(6, 1457)
      print(string.format("TEST-2...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 11118121133111045, "inputs": {"n": 33}}, {"idx": 1, "outputs": 13121, "inputs": {"n": 8}}, {"idx": 2, "outputs": 1457, "inputs": {"n": 6}}]