title: Hexagonal Number
signature: function hexagonal_number(n)
source_py: def hexagonal_number(n):
      return (n * ((2 * n) - 1))
source_cpp: int hexagonal_number(int n) {
    return n * ( 2 * n - 1 );
  }
question_info.entry_fn_name: hexagonal_number
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
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(38, 2850)
      print(string.format("TEST-0...%s",result))
  
      result = driver(44, 3828)
      print(string.format("TEST-1...%s",result))
  
      result = driver(58, 6670)
      print(string.format("TEST-2...%s",result))
  
      result = driver(10, 190)
      print(string.format("TEST-3...%s",result))
  
      result = driver(31, 1891)
      print(string.format("TEST-4...%s",result))
  
      result = driver(53, 5565)
      print(string.format("TEST-5...%s",result))
  
      result = driver(94, 17578)
      print(string.format("TEST-6...%s",result))
  
      result = driver(64, 8128)
      print(string.format("TEST-7...%s",result))
  
      result = driver(71, 10011)
      print(string.format("TEST-8...%s",result))
  
      result = driver(59, 6903)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 2850, "inputs": {"n": 38}}, {"idx": 1, "outputs": 3828, "inputs": {"n": 44}}, {"idx": 2, "outputs": 6670, "inputs": {"n": 58}}, {"idx": 3, "outputs": 190, "inputs": {"n": 10}}, {"idx": 4, "outputs": 1891, "inputs": {"n": 31}}, {"idx": 5, "outputs": 5565, "inputs": {"n": 53}}, {"idx": 6, "outputs": 17578, "inputs": {"n": 94}}, {"idx": 7, "outputs": 8128, "inputs": {"n": 64}}, {"idx": 8, "outputs": 10011, "inputs": {"n": 71}}, {"idx": 9, "outputs": 6903, "inputs": {"n": 59}}]