title: Remainder 7 Large Numbers
signature: func remainder7LargeNumbers(num string) 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(num string, expected int) string {
      if validateSolution(PLACEHOLDER_FN_NAME(num),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver("K", 6)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver("850076", 3)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver("00111", 6)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver("X", 5)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver("1", 1)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver("10010001100", 1)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(" pgPeLz", 0)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver("53212456821275", 3)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver("101", 3)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver("V", 3)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
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;
    }