title: Count Frequency K Matrix Size N Matrixi J Ij
signature: function count_frequency_k_matrix_size_n_matrixi_j_ij(n, k)
source_py: def count_frequency_k_matrix_size_n_matrixi_j_ij(n, k):
      if ((n + 1) >= k):
          return (k - 1)
      else:
          return (((2 * n) + 1) - k)
source_cpp: int count_frequency_k_matrix_size_n_matrixi_j_ij(int n, int k) {
    if ( n + 1 >= k ) return ( k - 1 );
    else return ( 2 * n + 1 - k );
  }
question_info.entry_fn_name: count_frequency_k_matrix_size_n_matrixi_j_ij
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
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(n, k, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(n, k) 
      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(90, 74, 73)
      print(string.format("TEST-0...%s",result))
  
      result = driver(86, 36, 35)
      print(string.format("TEST-1...%s",result))
  
      result = driver(92, 38, 37)
      print(string.format("TEST-2...%s",result))
  
      result = driver(72, 71, 70)
      print(string.format("TEST-3...%s",result))
  
      result = driver(25, 57, -6)
      print(string.format("TEST-4...%s",result))
  
      result = driver(11, 53, -30)
      print(string.format("TEST-5...%s",result))
  
      result = driver(94, 80, 79)
      print(string.format("TEST-6...%s",result))
  
      result = driver(91, 75, 74)
      print(string.format("TEST-7...%s",result))
  
      result = driver(66, 58, 57)
      print(string.format("TEST-8...%s",result))
  
      result = driver(34, 88, -19)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 73, "inputs": {"n": 90, "k": 74}}, {"idx": 1, "outputs": 35, "inputs": {"n": 86, "k": 36}}, {"idx": 2, "outputs": 37, "inputs": {"n": 92, "k": 38}}, {"idx": 3, "outputs": 70, "inputs": {"n": 72, "k": 71}}, {"idx": 4, "outputs": -6, "inputs": {"n": 25, "k": 57}}, {"idx": 5, "outputs": -30, "inputs": {"n": 11, "k": 53}}, {"idx": 6, "outputs": 79, "inputs": {"n": 94, "k": 80}}, {"idx": 7, "outputs": 74, "inputs": {"n": 91, "k": 75}}, {"idx": 8, "outputs": 57, "inputs": {"n": 66, "k": 58}}, {"idx": 9, "outputs": -19, "inputs": {"n": 34, "k": 88}}]