title: Number Days Tank Will Become Empty
signature: function number_days_tank_will_become_empty(c, l)
source_py: def number_days_tank_will_become_empty(C, l):
      if (l >= C):
          return C
      eq_root = ((math.sqrt((1 + (8 * (C - l)))) - 1) / 2)
      return (math.ceil(eq_root) + l)
source_cpp: int number_days_tank_will_become_empty(int C, int l) {
    if ( l >= C ) return C;
    double eq_root = ( std :: sqrt ( 1 + 8 * ( C - l ) ) - 1 ) / 2;
    return std :: ceil ( eq_root ) + l;
  }
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(c, l, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(c, l) 
      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(91, 29, 40)
      print(string.format("TEST-0...%s",result))
  
      result = driver(99, 55, 64)
      print(string.format("TEST-1...%s",result))
  
      result = driver(11, 56, 11)
      print(string.format("TEST-2...%s",result))
  
      result = driver(23, 56, 23)
      print(string.format("TEST-3...%s",result))
  
      result = driver(12, 97, 12)
      print(string.format("TEST-4...%s",result))
  
      result = driver(1, 64, 1)
      print(string.format("TEST-5...%s",result))
  
      result = driver(18, 5, 10)
      print(string.format("TEST-6...%s",result))
  
      result = driver(14, 37, 14)
      print(string.format("TEST-7...%s",result))
  
      result = driver(13, 55, 13)
      print(string.format("TEST-8...%s",result))
  
      result = driver(36, 99, 36)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 40, "inputs": {"c": 91, "l": 29}}, {"idx": 1, "outputs": 64, "inputs": {"c": 99, "l": 55}}, {"idx": 2, "outputs": 11, "inputs": {"c": 11, "l": 56}}, {"idx": 3, "outputs": 23, "inputs": {"c": 23, "l": 56}}, {"idx": 4, "outputs": 12, "inputs": {"c": 12, "l": 97}}, {"idx": 5, "outputs": 1, "inputs": {"c": 1, "l": 64}}, {"idx": 6, "outputs": 10, "inputs": {"c": 18, "l": 5}}, {"idx": 7, "outputs": 14, "inputs": {"c": 14, "l": 37}}, {"idx": 8, "outputs": 13, "inputs": {"c": 13, "l": 55}}, {"idx": 9, "outputs": 36, "inputs": {"c": 36, "l": 99}}]
question_info.extension: lua
question_info.entry_fn_name: number_days_tank_will_become_empty
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__