title: Distributing M Items Circle Size N Starting K Th Position
signature: func distributingMItemsCircleSizeNStartingKThPosition(n int, m int, k int) int {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual int, expected int) bool {
      return reflect.DeepEqual(actual,expected)
  }
  
  func driver(n int, m int, k int, expected int) string {
      if validateSolution(PLACEHOLDER_FN_NAME(n, m, k),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(19, 
  	14, 
  	34, 9)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(23, 
  	51, 
  	5, 9)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(92, 
  	10, 
  	24, 33)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(9, 
  	50, 
  	34, 2)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(20, 
  	67, 
  	20, 6)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(68, 
  	25, 
  	40, 64)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(66, 
  	30, 
  	24, 53)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(77, 
  	22, 
  	32, 53)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(90, 
  	1, 
  	71, 71)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(26, 
  	34, 
  	54, 9)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
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 );
  }