title: Horners Method Polynomial Evaluation
signature: function horners_method_polynomial_evaluation(poly, n, x)
source_py: def horners_method_polynomial_evaluation(poly, n, x):
      result = poly[0]
      for i in range(1, n):
          result = ((result * x) + poly[i])
      return result
source_cpp: int horners_method_polynomial_evaluation(vector<int> poly, int n, int x) {
    int result = poly [ 0 ];
    for ( int i = 1;
    i < n;
    i ++ ) result = result * x + poly [ i ];
    return result;
  }
question_info.entry_fn_name: horners_method_polynomial_evaluation
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(poly, n, x, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(poly, n, x) 
      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({0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1}, 10, 8, 73)
      print(string.format("TEST-0...%s",result))
  
      result = driver({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 20, 23, 292561)
      print(string.format("TEST-1...%s",result))
  
      result = driver({86, 62, 30, 27, 98, 75, 93, 37, 70, 16, 20, 74, 46, 74, 25, 59, 86, 32, 17, 90, 80, 10, 17}, 12, 12, 67907758875578)
      print(string.format("TEST-2...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 73, "inputs": {"poly": [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1], "n": 10, "x": 8}}, {"idx": 1, "outputs": 292561, "inputs": {"poly": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 20, "x": 23}}, {"idx": 2, "outputs": 67907758875578, "inputs": {"poly": [86, 62, 30, 27, 98, 75, 93, 37, 70, 16, 20, 74, 46, 74, 25, 59, 86, 32, 17, 90, 80, 10, 17], "n": 12, "x": 12}}]