title: Remainder 7 Large Numbers
signature: int remainder7LargeNumbers(string num) {
test_code: #include <algorithm>
  #include <assert.h>
  #include <cstdlib>
  #include <iostream>
  #include <map>
  #include <set>
  #include <string>
  #include <tuple> 
  #include <unordered_map>
  #include <vector>
  #include <math.h>
  #include <cmath>
  #include <bits/stdc++.h>
  #include <numeric>
  #include <functional>
  
  using namespace std;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(int actual, int expected){
      return actual == expected;
  }
  
  string driver(string num, int expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(num), expected)){
              return "PASSED";
          }
          return "FAILED";
      }
      catch (const std::overflow_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::runtime_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::exception& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (...)
      {
          return "UNK_ERROR";
      }
  }
  
  int main() {
      string result = "";
  
      result = driver("K", 6); 
      cout << "TEST-" << 0 << "..."
           <<  result
           << "\n";
  
      result = driver("850076", 3); 
      cout << "TEST-" << 1 << "..."
           <<  result
           << "\n";
  
      result = driver("00111", 6); 
      cout << "TEST-" << 2 << "..."
           <<  result
           << "\n";
  
      result = driver("X", 5); 
      cout << "TEST-" << 3 << "..."
           <<  result
           << "\n";
  
      result = driver("1", 1); 
      cout << "TEST-" << 4 << "..."
           <<  result
           << "\n";
  
      result = driver("10010001100", 1); 
      cout << "TEST-" << 5 << "..."
           <<  result
           << "\n";
  
      result = driver(" pgPeLz", 0); 
      cout << "TEST-" << 6 << "..."
           <<  result
           << "\n";
  
      result = driver("53212456821275", 3); 
      cout << "TEST-" << 7 << "..."
           <<  result
           << "\n";
  
      result = driver("101", 3); 
      cout << "TEST-" << 8 << "..."
           <<  result
           << "\n";
  
      result = driver("V", 3); 
      cout << "TEST-" << 9 << "..."
           <<  result
           << "\n";
  
      return 0;
  }
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;
    }