title: Remainder 7 Large Numbers
signature: remainder_7_large_numbers <- function(num) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(num, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(num), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          "K", 
          6L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          "850076", 
          3L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          "00111", 
          6L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          "X", 
          5L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          "1", 
          1L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          "10010001100", 
          1L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          " pgPeLz", 
          0L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          "53212456821275", 
          3L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          "101", 
          3L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          "V", 
          3L
      )))
  
  }
  
  main()
source_py: def remainder_7_large_numbers(num):
      series = [1, 3, 2, (- 1), (- 3), (- 2)]
      series_index = 0
      result = 0
      for i in range((len(num) - 1), (- 1), (- 1)):
          digit = (ord(num[i]) - 48)
          result += (digit * series[series_index])
          series_index = ((series_index + 1) % 6)
          result %= 7
      if (result < 0):
          result = ((result + 7) % 7)
      return result
source_cpp: int remainder_7_large_numbers(string num) {
    int series [ ] = {
      1, 3, 2, - 1, - 3, - 2 };
      int series_index = 0;
      int result = 0;
      for ( int i = num . size ( ) - 1;
      i >= 0;
      i -- ) {
        int digit = num [ i ] - '0';
        result += digit * series [ series_index ];
        series_index = ( series_index + 1 ) % 6;
        result %= 7;
      }
      if ( result < 0 ) result = ( result + 7 ) % 7;
      return result;
    }