title: Distributing M Items Circle Size N Starting K Th Position
signature: function distributing_m_items_circle_size_n_starting_k_th_position(n, m, k)
source_py: def distributing_m_items_circle_size_n_starting_k_th_position(n, m, k):
      if (m <= ((n - k) + 1)):
          return ((m + k) - 1)
      m = (m - ((n - k) + 1))
      if ((m % n) == 0):
          return n
      else:
          return (m % n)
source_cpp: int distributing_m_items_circle_size_n_starting_k_th_position(int n, int m, int k) {
    if ( m <= n - k + 1 ) return m + k - 1;
    m = m - ( n - k + 1 );
    return ( m % n == 0 ) ? n : ( m % n );
  }
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, m, k, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(n, m, 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(19, 14, 34, 9)
      print(string.format("TEST-0...%s",result))
  
      result = driver(23, 51, 5, 9)
      print(string.format("TEST-1...%s",result))
  
      result = driver(92, 10, 24, 33)
      print(string.format("TEST-2...%s",result))
  
      result = driver(9, 50, 34, 2)
      print(string.format("TEST-3...%s",result))
  
      result = driver(20, 67, 20, 6)
      print(string.format("TEST-4...%s",result))
  
      result = driver(68, 25, 40, 64)
      print(string.format("TEST-5...%s",result))
  
      result = driver(66, 30, 24, 53)
      print(string.format("TEST-6...%s",result))
  
      result = driver(77, 22, 32, 53)
      print(string.format("TEST-7...%s",result))
  
      result = driver(90, 1, 71, 71)
      print(string.format("TEST-8...%s",result))
  
      result = driver(26, 34, 54, 9)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 9, "inputs": {"n": 19, "m": 14, "k": 34}}, {"idx": 1, "outputs": 9, "inputs": {"n": 23, "m": 51, "k": 5}}, {"idx": 2, "outputs": 33, "inputs": {"n": 92, "m": 10, "k": 24}}, {"idx": 3, "outputs": 2, "inputs": {"n": 9, "m": 50, "k": 34}}, {"idx": 4, "outputs": 6, "inputs": {"n": 20, "m": 67, "k": 20}}, {"idx": 5, "outputs": 64, "inputs": {"n": 68, "m": 25, "k": 40}}, {"idx": 6, "outputs": 53, "inputs": {"n": 66, "m": 30, "k": 24}}, {"idx": 7, "outputs": 53, "inputs": {"n": 77, "m": 22, "k": 32}}, {"idx": 8, "outputs": 71, "inputs": {"n": 90, "m": 1, "k": 71}}, {"idx": 9, "outputs": 9, "inputs": {"n": 26, "m": 34, "k": 54}}]
question_info.extension: lua
question_info.entry_fn_name: distributing_m_items_circle_size_n_starting_k_th_position
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__