title: Minimum Rotations Unlock Circular Lock
signature: minimum_rotations_unlock_circular_lock <- function(input, unlock_code) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(input, unlock_code, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(input, unlock_code), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          71L, 46L, 
          8L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          90L, 65L, 
          8L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          28L, 84L, 
          8L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          41L, 23L, 
          4L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          32L, 58L, 
          6L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          39L, 82L, 
          8L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          33L, 58L, 
          7L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          89L, 32L, 
          8L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          50L, 51L, 
          1L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          92L, 77L, 
          7L
      )))
  
  }
  
  main()
source_py: def minimum_rotations_unlock_circular_lock(input, unlock_code):
      rotation = 0
      while ((input > 0) or (unlock_code > 0)):
          input_digit = (input % 10)
          code_digit = (unlock_code % 10)
          rotation += min(abs((input_digit - code_digit)), (10 - abs((input_digit - code_digit))))
          input = int((input / 10))
          unlock_code = int((unlock_code / 10))
      return rotation
source_cpp: int minimum_rotations_unlock_circular_lock(int input, int unlock_code) {
    int rotation = 0;
    int input_digit, code_digit;
    while ( input || unlock_code ) {
      input_digit = input % 10;
      code_digit = unlock_code % 10;
      rotation += min ( abs ( input_digit - code_digit ), 10 - abs ( input_digit - code_digit ) );
      input /= 10;
      unlock_code /= 10;
    }
    return rotation;
  }