title: Middle Of Three Using Minimum Comparisons 1
signature: function middle_of_three_using_minimum_comparisons_1(a, b, c)
source_py: def middle_of_three_using_minimum_comparisons_1(a, b, c):
      if (a > b):
          if (b > c):
              return b
          elif (a > c):
              return c
          else:
              return a
      elif (a > c):
          return a
      elif (b > c):
          return c
      else:
          return b
source_cpp: int middle_of_three_using_minimum_comparisons_1(int a, int b, int c) {
    if ( a > b ) {
      if ( b > c ) return b;
      else if ( a > c ) return c;
      else return a;
    }
    else {
      if ( a > c ) return a;
      else if ( b > c ) return c;
      else return b;
    }
  }
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, c, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(a, b, c) 
      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(43, 24, 7, 24)
      print(string.format("TEST-0...%s",result))
  
      result = driver(76, 54, 66, 66)
      print(string.format("TEST-1...%s",result))
  
      result = driver(57, 5, 40, 40)
      print(string.format("TEST-2...%s",result))
  
      result = driver(10, 13, 4, 10)
      print(string.format("TEST-3...%s",result))
  
      result = driver(59, 47, 56, 56)
      print(string.format("TEST-4...%s",result))
  
      result = driver(92, 14, 50, 50)
      print(string.format("TEST-5...%s",result))
  
      result = driver(49, 62, 65, 62)
      print(string.format("TEST-6...%s",result))
  
      result = driver(16, 95, 12, 16)
      print(string.format("TEST-7...%s",result))
  
      result = driver(33, 41, 90, 41)
      print(string.format("TEST-8...%s",result))
  
      result = driver(66, 63, 46, 63)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 24, "inputs": {"a": 43, "b": 24, "c": 7}}, {"idx": 1, "outputs": 66, "inputs": {"a": 76, "b": 54, "c": 66}}, {"idx": 2, "outputs": 40, "inputs": {"a": 57, "b": 5, "c": 40}}, {"idx": 3, "outputs": 10, "inputs": {"a": 10, "b": 13, "c": 4}}, {"idx": 4, "outputs": 56, "inputs": {"a": 59, "b": 47, "c": 56}}, {"idx": 5, "outputs": 50, "inputs": {"a": 92, "b": 14, "c": 50}}, {"idx": 6, "outputs": 62, "inputs": {"a": 49, "b": 62, "c": 65}}, {"idx": 7, "outputs": 16, "inputs": {"a": 16, "b": 95, "c": 12}}, {"idx": 8, "outputs": 41, "inputs": {"a": 33, "b": 41, "c": 90}}, {"idx": 9, "outputs": 63, "inputs": {"a": 66, "b": 63, "c": 46}}]
question_info.extension: lua
question_info.entry_fn_name: middle_of_three_using_minimum_comparisons_1
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__