title: Decimal Representation Given Binary String Divisible 10 Not
signature: class Solution {
  
      public Boolean decimalRepresentationGivenBinaryStringDivisible10Not(String bin) {
test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(String bin, Boolean expected){
          try{
              Driver driver = new Driver();
              if (driver.run(bin,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution("101000", true);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution("39613456759141", false);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution("11", false);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution("PoiHjo", true);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution("2", true);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution("0000101", false);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution("T  s dZKeDX gK", true);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution("3944713969", false);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution("1000", false);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution("ifYUgdpmt", true);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(String bin, Boolean expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(bin),expected);
      }
      
      public boolean validateSolution(Boolean actual, Boolean expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
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;
  }