title: Distributing M Items Circle Size N Starting K Th Position
signature: distributing_m_items_circle_size_n_starting_k_th_position <- function(n, m, k) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(n, m, k, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(n, m, k), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          19L, 14L, 34L, 
          9L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          23L, 51L, 5L, 
          9L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          92L, 10L, 24L, 
          33L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          9L, 50L, 34L, 
          2L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          20L, 67L, 20L, 
          6L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          68L, 25L, 40L, 
          64L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          66L, 30L, 24L, 
          53L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          77L, 22L, 32L, 
          53L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          90L, 1L, 71L, 
          71L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          26L, 34L, 54L, 
          9L
      )))
  
  }
  
  main()
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 );
  }