title: Compute Average Two Numbers Without Overflow 1
signature: function compute_average_two_numbers_without_overflow_1(a, b)
source_py: def compute_average_two_numbers_without_overflow_1(a, b):
      return (((a // 2) + (b // 2)) + (((a % 2) + (b % 2)) // 2))
source_cpp: int compute_average_two_numbers_without_overflow_1(int a, int b) {
    return ( a / 2 ) + ( b / 2 ) + ( ( a % 2 + b % 2 ) / 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(a, b, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(a, b) 
      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(9, 81, 45)
      print(string.format("TEST-0...%s",result))
  
      result = driver(68, 79, 73)
      print(string.format("TEST-1...%s",result))
  
      result = driver(51, 2, 26)
      print(string.format("TEST-2...%s",result))
  
      result = driver(31, 49, 40)
      print(string.format("TEST-3...%s",result))
  
      result = driver(14, 10, 12)
      print(string.format("TEST-4...%s",result))
  
      result = driver(73, 9, 41)
      print(string.format("TEST-5...%s",result))
  
      result = driver(51, 13, 32)
      print(string.format("TEST-6...%s",result))
  
      result = driver(75, 67, 71)
      print(string.format("TEST-7...%s",result))
  
      result = driver(98, 51, 74)
      print(string.format("TEST-8...%s",result))
  
      result = driver(83, 74, 78)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 45, "inputs": {"a": 9, "b": 81}}, {"idx": 1, "outputs": 73, "inputs": {"a": 68, "b": 79}}, {"idx": 2, "outputs": 26, "inputs": {"a": 51, "b": 2}}, {"idx": 3, "outputs": 40, "inputs": {"a": 31, "b": 49}}, {"idx": 4, "outputs": 12, "inputs": {"a": 14, "b": 10}}, {"idx": 5, "outputs": 41, "inputs": {"a": 73, "b": 9}}, {"idx": 6, "outputs": 32, "inputs": {"a": 51, "b": 13}}, {"idx": 7, "outputs": 71, "inputs": {"a": 75, "b": 67}}, {"idx": 8, "outputs": 74, "inputs": {"a": 98, "b": 51}}, {"idx": 9, "outputs": 78, "inputs": {"a": 83, "b": 74}}]
question_info.extension: lua
question_info.entry_fn_name: compute_average_two_numbers_without_overflow_1
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__