title: Program To Find Remainder Without Using Modulo Or Operator 2
signature: function program_to_find_remainder_without_using_modulo_or_operator_2(num, divisor)
source_py: def program_to_find_remainder_without_using_modulo_or_operator_2(num, divisor):
      while (num >= divisor):
          num -= divisor
      return num
source_cpp: int program_to_find_remainder_without_using_modulo_or_operator_2(int num, int divisor) {
    while ( num >= divisor ) num -= divisor;
    return num;
  }
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(num, divisor, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(num, divisor) 
      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(70, 13, 5)
      print(string.format("TEST-0...%s",result))
  
      result = driver(77, 3, 2)
      print(string.format("TEST-1...%s",result))
  
      result = driver(77, 73, 4)
      print(string.format("TEST-2...%s",result))
  
      result = driver(88, 54, 34)
      print(string.format("TEST-3...%s",result))
  
      result = driver(96, 39, 18)
      print(string.format("TEST-4...%s",result))
  
      result = driver(6, 10, 6)
      print(string.format("TEST-5...%s",result))
  
      result = driver(79, 95, 79)
      print(string.format("TEST-6...%s",result))
  
      result = driver(44, 32, 12)
      print(string.format("TEST-7...%s",result))
  
      result = driver(26, 86, 26)
      print(string.format("TEST-8...%s",result))
  
      result = driver(82, 91, 82)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 5, "inputs": {"num": 70, "divisor": 13}}, {"idx": 1, "outputs": 2, "inputs": {"num": 77, "divisor": 3}}, {"idx": 2, "outputs": 4, "inputs": {"num": 77, "divisor": 73}}, {"idx": 3, "outputs": 34, "inputs": {"num": 88, "divisor": 54}}, {"idx": 4, "outputs": 18, "inputs": {"num": 96, "divisor": 39}}, {"idx": 5, "outputs": 6, "inputs": {"num": 6, "divisor": 10}}, {"idx": 6, "outputs": 79, "inputs": {"num": 79, "divisor": 95}}, {"idx": 7, "outputs": 12, "inputs": {"num": 44, "divisor": 32}}, {"idx": 8, "outputs": 26, "inputs": {"num": 26, "divisor": 86}}, {"idx": 9, "outputs": 82, "inputs": {"num": 82, "divisor": 91}}]
question_info.extension: lua
question_info.entry_fn_name: program_to_find_remainder_without_using_modulo_or_operator_2
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__