title: Decimal Representation Given Binary String Divisible 10 Not
signature: bool decimalRepresentationGivenBinaryStringDivisible10Not(string bin) {
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(bool actual, bool expected){
      return actual == expected;
  }
  
  string driver(string bin, bool expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(bin), 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("101000", true); 
      cout << "TEST-" << 0 << "..."
           <<  result
           << "\n";
  
      result = driver("39613456759141", false); 
      cout << "TEST-" << 1 << "..."
           <<  result
           << "\n";
  
      result = driver("11", false); 
      cout << "TEST-" << 2 << "..."
           <<  result
           << "\n";
  
      result = driver("PoiHjo", true); 
      cout << "TEST-" << 3 << "..."
           <<  result
           << "\n";
  
      result = driver("2", true); 
      cout << "TEST-" << 4 << "..."
           <<  result
           << "\n";
  
      result = driver("0000101", false); 
      cout << "TEST-" << 5 << "..."
           <<  result
           << "\n";
  
      result = driver("T  s dZKeDX gK", true); 
      cout << "TEST-" << 6 << "..."
           <<  result
           << "\n";
  
      result = driver("3944713969", false); 
      cout << "TEST-" << 7 << "..."
           <<  result
           << "\n";
  
      result = driver("1000", false); 
      cout << "TEST-" << 8 << "..."
           <<  result
           << "\n";
  
      result = driver("ifYUgdpmt", true); 
      cout << "TEST-" << 9 << "..."
           <<  result
           << "\n";
  
      return 0;
  }
source_py: def decimal_representation_given_binary_string_divisible_10_not(bin):
      n = len(bin)
      if (bin[(n - 1)] == '1'):
          return False
      sum = 0
      i = (n - 2)
      while (i >= 0):
          if (bin[i] == '1'):
              posFromRight = ((n - i) - 1)
              if ((posFromRight % 4) == 1):
                  sum = (sum + 2)
              elif ((posFromRight % 4) == 2):
                  sum = (sum + 4)
              elif ((posFromRight % 4) == 3):
                  sum = (sum + 8)
              elif ((posFromRight % 4) == 0):
                  sum = (sum + 6)
          i = (i - 1)
      if ((sum % 10) == 0):
          return True
      return False
source_cpp: bool decimal_representation_given_binary_string_divisible_10_not(string bin) {
    int n = bin . size ( );
    if ( bin [ n - 1 ] == '1' ) return false;
    int sum = 0;
    for ( int i = n - 2;
    i >= 0;
    i -- ) {
      if ( bin [ i ] == '1' ) {
        int posFromRight = n - i - 1;
        if ( posFromRight % 4 == 1 ) sum = sum + 2;
        else if ( posFromRight % 4 == 2 ) sum = sum + 4;
        else if ( posFromRight % 4 == 3 ) sum = sum + 8;
        else if ( posFromRight % 4 == 0 ) sum = sum + 6;
      }
    }
    if ( sum % 10 == 0 ) return true;
    return false;
  }