title: Modulus Two Float Double Numbers
signature: function modulus_two_float_double_numbers(a, b)
source_py: def modulus_two_float_double_numbers(a, b):
      if (a < 0):
          a = (- a)
      if (b < 0):
          b = (- b)
      mod = a
      while (mod >= b):
          mod = (mod - b)
      if (a < 0):
          return (- mod)
      return mod
source_cpp: double modulus_two_float_double_numbers(double a, double b) {
    double mod;
    if ( a < 0 ) mod = - a;
    else mod = a;
    if ( b < 0 ) b = - b;
    while ( mod >= b ) mod = mod - b;
    if ( a < 0 ) return - mod;
    return mod;
  }
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 math.abs(actual - expected) < 1e-09
  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(3243.229719038493, 5659.926861939672, 3243.229719038493)
      print(string.format("TEST-0...%s",result))
  
      result = driver(-4362.665881044217, -9196.507113304497, 4362.665881044217)
      print(string.format("TEST-1...%s",result))
  
      result = driver(7255.066257575837, 2623.200060506935, 2008.6661365619666)
      print(string.format("TEST-2...%s",result))
  
      result = driver(-6929.554320261099, -3009.0234530313287, 911.5074141984414)
      print(string.format("TEST-3...%s",result))
  
      result = driver(3569.942027998315, 6920.809419868375, 3569.942027998315)
      print(string.format("TEST-4...%s",result))
  
      result = driver(-6513.849053096595, -70.95992406437102, 56.49596323882673)
      print(string.format("TEST-5...%s",result))
  
      result = driver(7333.183189243961, 580.3500610971768, 368.98245607783906)
      print(string.format("TEST-6...%s",result))
  
      result = driver(-2856.1752826258803, -9625.97442825802, 2856.1752826258803)
      print(string.format("TEST-7...%s",result))
  
      result = driver(9787.228111241662, 2419.6844962423256, 108.4901262723597)
      print(string.format("TEST-8...%s",result))
  
      result = driver(-1722.873699288031, -8370.700544254058, 1722.873699288031)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 3243.229719038493, "inputs": {"a": 3243.229719038493, "b": 5659.926861939672}}, {"idx": 1, "outputs": 4362.665881044217, "inputs": {"a": -4362.665881044217, "b": -9196.507113304497}}, {"idx": 2, "outputs": 2008.6661365619666, "inputs": {"a": 7255.066257575837, "b": 2623.200060506935}}, {"idx": 3, "outputs": 911.5074141984414, "inputs": {"a": -6929.554320261099, "b": -3009.0234530313287}}, {"idx": 4, "outputs": 3569.942027998315, "inputs": {"a": 3569.942027998315, "b": 6920.809419868375}}, {"idx": 5, "outputs": 56.49596323882673, "inputs": {"a": -6513.849053096595, "b": -70.95992406437102}}, {"idx": 6, "outputs": 368.98245607783906, "inputs": {"a": 7333.183189243961, "b": 580.3500610971768}}, {"idx": 7, "outputs": 2856.1752826258803, "inputs": {"a": -2856.1752826258803, "b": -9625.97442825802}}, {"idx": 8, "outputs": 108.4901262723597, "inputs": {"a": 9787.228111241662, "b": 2419.6844962423256}}, {"idx": 9, "outputs": 1722.873699288031, "inputs": {"a": -1722.873699288031, "b": -8370.700544254058}}]
question_info.extension: lua
question_info.entry_fn_name: modulus_two_float_double_numbers
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__