title: Decimal Representation Given Binary String Divisible 10 Not
signature: function decimalRepresentationGivenBinaryStringDivisible10Not(bin: string): boolean {
test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: boolean, expected: boolean): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(bin: string, expected:boolean): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(bin),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver("101000", true);
    console.log(`TEST-0...${result}`);
  
    result = driver("39613456759141", false);
    console.log(`TEST-1...${result}`);
  
    result = driver("11", false);
    console.log(`TEST-2...${result}`);
  
    result = driver("PoiHjo", true);
    console.log(`TEST-3...${result}`);
  
    result = driver("2", true);
    console.log(`TEST-4...${result}`);
  
    result = driver("0000101", false);
    console.log(`TEST-5...${result}`);
  
    result = driver("T  s dZKeDX gK", true);
    console.log(`TEST-6...${result}`);
  
    result = driver("3944713969", false);
    console.log(`TEST-7...${result}`);
  
    result = driver("1000", false);
    console.log(`TEST-8...${result}`);
  
    result = driver("ifYUgdpmt", true);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
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;
  }