title: Remainder 7 Large Numbers
signature: function remainder7LargeNumbers($num) {
test_code: <?php
  
  
  // SOLUTION CODE 
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function validateSolution($actual, $expected){
      return serialize($actual) == serialize($expected);
  }
  
  function driver($num, $expected){
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME($num), $expected)){
          return "PASSED";
        }
        return "FAILED";
      }
      catch (Exception $exception_obj) {
        return get_class($exception_obj);
      }
  }
  
  function main(){
      printf("TEST-0...%s\n",driver(
        "K", 
        6));
      
      printf("TEST-1...%s\n",driver(
        "850076", 
        3));
      
      printf("TEST-2...%s\n",driver(
        "00111", 
        6));
      
      printf("TEST-3...%s\n",driver(
        "X", 
        5));
      
      printf("TEST-4...%s\n",driver(
        "1", 
        1));
      
      printf("TEST-5...%s\n",driver(
        "10010001100", 
        1));
      
      printf("TEST-6...%s\n",driver(
        " pgPeLz", 
        0));
      
      printf("TEST-7...%s\n",driver(
        "53212456821275", 
        3));
      
      printf("TEST-8...%s\n",driver(
        "101", 
        3));
      
      printf("TEST-9...%s\n",driver(
        "V", 
        3));
      
  }
  
  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;
    }